Nordic Collegiate Programming Contest (NCPC) 2016
A Artwork
B Bless You Autocorrect!
C Card Hand Sorting
D Daydreaming Stockbroker
贪心,低买高卖,不要爆int。
#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> using namespace std; typedef long long LL; const int maxn=400; const int INF=2147000000; LL p[maxn]; int d,n; LL mo,sh; int main(){ scanf("%d",&d); LL a,num=0; for(int i=1;i<=d;i++){ scanf("%lld",&a); if(a!=p[num]){ num++; p[num]=a; } } d=num; p[0]=INF,p[d+1]=-INF; mo=100,sh=0; for(int i=1;i<=d;i++){ if(p[i]<p[i-1]&&p[i]<p[i+1]&&mo>=p[i]){ LL num=mo/p[i]; if(num>100000){ sh+=100000; mo-=p[i]*100000; }else{ sh+=num; mo-=p[i]*num; } } if(p[i]>p[i-1]&&p[i]>p[i+1]&&sh){ mo+=p[i]*sh; sh=0; } } printf("%lld\n",mo); return 0; }
E Exponial
F Fleecing the Raffle
G Game Rank
炉石传说的rank机制。直接模拟就好。
#include <bits/stdc++.h> using namespace std; const int maxn = 10010; int up(int x) { if (x >= 21) return 2; if (x >= 16) return 3; if (x >= 11) return 4; if (x >= 1) return 5; return 0x3f3f3f3f; } int main() { char s[maxn]; scanf("%s", s); int tmp = 0; int rak = 25, star = 0; for (int i = 0; s[i]; i++) { if (s[i] == 'W') { ++tmp, ++star; if (tmp >= 3 && rak > 5) star++; } else { if ((rak > 0 && rak < 20) || (rak == 20 && star)) star--; tmp = 0; } if (star > up(rak)) { star -= up(rak); rak--; } if (star < 0) { rak++; star = up(rak)-1; } } if (rak < 1) printf("Legend\n"); else printf("%d\n", rak); return 0; }
H Highest Tower
I Interception
J Jumbled Compass
签到
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n1,n2; int main(){ scanf("%d%d",&n1,&n2); int a1 = n1-n2; int a2 = 360-abs(a1); if(a1 > 0) { if(a1 >= 180) printf("%d\n", a2); else printf("-%d", abs(a1)); } else { if(abs(a1) > 180) printf("-%d\n", a2); else printf("%d", abs(a1)); } return 0; }
K Keeping the Dogs Apart