Educational Codeforces Round 100
阿新 • • 發佈:2020-12-18
\(noip\)之後頹廢了一段時間了,現在月考考完了,還是決定幹正事。
這場比賽是我賽後打的,沒有\(Virtual\quad Contest\),直接腦補畫面,比較噁心。
總之題還是題,做了就是做了,沒做就是沒做。
\(A. Dungeon\)
話說\(T1\)沒看出結論整個人心態都是崩的。
結論是:合為\(9\)的倍數,且最小數能支撐到最後一刻。
程式碼如下,僅供參考:
#include<bits/stdc++.h> using namespace std; #define inf 1e9 const int maxn=2e5+10; const int mod=1e9+7; inline int read(){ int x=0,f=1;char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();} return x*f; } int T,a,b,c,sum,mn; int main(){ T=read(); while(T--){ a=read(),b=read(),c=read(); sum=a+b+c,mn=min(min(a,b),c); if(sum%9||sum<9||mn*9<sum)puts("NO"); else puts("YES"); } return 0; }
\(B. Find The Array\)
感覺好久不搞\(oi\)人都頹了,腦子都笨了。
巧妙地利用\(2\)的冪次可以將\(|a_i-b_i|\)控制在\(\frac12a_i\)以內。
程式碼如下,僅供參考:
#include<bits/stdc++.h> using namespace std; #define int long long #define inf 1e9 const int maxn=2e5+10; const int mod=1e9+7; int T,n,a[maxn],pre[maxn]; inline int read(){ int x=0,f=1;char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();} return x*f; } signed main(){ T=read();pre[0]=1; for(int i=1;i<=40;i++) pre[i]=pre[i-1]<<1; while(T--){ n=read(); for(int i=1;i<=n;i++) a[i]=read(); for(int i=1;i<=n;i++) printf("%lld ",pre[lower_bound(pre+1,pre+41,a[i])-pre-1]); puts(""); } return 0; }