AtCoder Grand Contest 019
最近比较懒,写了俩题就跑了
A - Ice Tea Store
简化背包
#include<cstdio> #include<algorithm> using namespace std; long long a,b,c,d,A,B,C,D,n,m; long long min(long long a,long long b){return a<b?a:b;} int main(){ scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&n);n*=4; A=a*8;B=b*4;C=c*2;D=d; if (A>B) A=B; if (A>C) A=C; if (A>D) A=D; printf("%lld\n",n/8*A+(n%8==4?min(a*4,min(c,min(a*2+b,b*2))):0)); }
B - Reverse and Compare
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <map> using namespace std; const int N = 2000010; char s[N], str[N*2]; int p[N*2],a[N]; long long manacher() { int i; for(i = 1; s[i]; i++) str[i*2] = s[i], str[i*2+1] = '#'; str[0] = '?', str[1] = '#', str[i*2] = '\0'; int res = 0, k = 0, maxk = 0,n=strlen(s+1); long long mmh=1LL*n*(n+1)/2; for (int i=1;i<=n;i++){ a[s[i]]++; mmh-=a[s[i]]; } return mmh+1; } int main() { scanf(" %s", s + 1); printf("%lld\n", manacher()); return 0; }
哇,后面的就永久留坑吧