AtCoder Beginner Contest 174 总结
這次做了ABDF。我也不知道我怎么做的(亂做-.-
A - Air Conditioner
簽到題1
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #define debug(x) cout<<#x<<": "<<x<<" " #include<iostream> #include<algorithm> using namespace std; int main() {IO;int T;cin>>T;if(T>=30) cout<<"Yes"<<endl;else cout<<"No"<<endl;return 0; }B - Distance
簽到題2
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #define debug(x) cout<<#x<<": "<<x<<" " #include<iostream> #include<algorithm> using namespace std; typedef long long ll; int main() {IO;int n;ll d;cin>>n>>d;int res=0;while(n--){ll x,y;cin>>x>>y;if(x*x+y*y<=d*d) res++;}cout<<res<<endl;return 0; }C - Repsept
群里大佬說k是2或5的倍速顯然不行,其他再int范圍內(nèi)顯然有解(為啥我看不出來顯然)。反正實(shí)在不行就暴力長度1…1071\dots10^71…107
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<iostream> #include<algorithm> using namespace std; typedef long long ll; int main() {IO;ll k;cin>>k;if(k%2==0||k%5==0){cout<<-1<<endl;return 0;}ll sum=0,len=1,p=1;while(true){sum=(sum+7*p)%k;if(sum==0) {cout<<len<<endl;break;}len++;p=p*10%k;}return 0; }反思:好幾次看到這種大數(shù)的都想著高精度,而且每次看到題解的時候都是因?yàn)槟A艘粋€數(shù)最終避免高精度。下次想高精度的時候需要考慮下是否能過模一個數(shù)避免高精度
D - Alter Altar
最終R全在左邊,W全在右邊,按照快排時候的策略,貪心+雙指針。
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #define debug(x) cout<<#x<<": "<<x<<" " #include<iostream> #include<algorithm> #include<string> using namespace std; typedef long long ll; int main() {IO;int n;string s;cin>>n>>s;int i=0,j=n-1;int res=0;while(i<j){if(s[i]=='R'&&s[j]=='W') i++,j--;else if(s[i]=='W'&&s[j]=='R') res++,i++,j--;else if(s[i]=='W'&&s[j]=='W') j--;else i++;}cout<<res<<endl;return 0; }E - Logs
最大值最小二分答案。u1s1這個題不難??荚囋趺礇]做!!!wctl
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int N=200010; int a[N],n,k; bool check(int mid) {ll res=0;for(int i=1;i<=n;i++) res+=(a[i]+mid-1)/mid-1;return res<=k; } int main() {IO;cin>>n>>k;for(int i=1;i<=n;i++) cin>>a[i];int l=1,r=1e9;while(l<r){int mid=l+r>>1;if(check(mid)) r=mid;else l=mid+1;}cout<<l<<endl;return 0; }F - Range Set Query
HH的項(xiàng)鏈
解法一:莫隊(duì)板子題5×1055×10^55×105過不了?那我開個O2還真讓我水過了(滑稽
O(mn)O(m\sqrt{n})O(mn?) 1953 ms
解法二:離線樹狀數(shù)組
對于求不同數(shù)的個數(shù),給定區(qū)間一個數(shù)出現(xiàn)n次對答案的貢獻(xiàn)只是1,我們不妨讓每次貢獻(xiàn)都看作是該區(qū)間最后這個數(shù)的出現(xiàn)給予的(前面出現(xiàn)的不算答案的貢獻(xiàn))。樹狀數(shù)組維護(hù)每個數(shù)對答案的貢獻(xiàn)。
O(mlogn+n)O(mlogn+n)O(mlogn+n) 222 ms
要加油哦~
總結(jié)
以上是生活随笔為你收集整理的AtCoder Beginner Contest 174 总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Codeforces Round #66
- 下一篇: Codeforces Round #66