2019江西省省赛
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 typedef long long ll; 5 char c[1000]; 6 ll l,k1,k2,k3,k4,k,kk,d; 7 8 int main(){ 9 while (~scanf("%lld",&l)) { 10 scanf("%s", c); 11 k1=k2=k3=k4=0; 12 for (int i = 0; i < l; i++) { 13 if (c[i] == 'a') k1++; 14 if (c[i] == 'v') k2++; 15 if (c[i] == 'i') k3++; 16 if (c[i] == 'n') k4++; 17 } 18 k = k2 * k1 * k3 * k4; 19 kk = l * l * l * l; 20 if (k == 0) { 21 printf("0/1\n"); 22 continue; 23 } 24 d = __gcd(k, kk); 25 k = k / d; 26 kk = kk / d; 27 printf("%lld/%lld\n", k, kk); 28 } 29 }
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int a[2000],b[2000],c[2000],d[2000],t,f,n,m; 5 int main() { 6 while (~scanf("%d%d",&n,&m)) { 7 for (int i = 1; i <= n; i++) { 8 scanf("%d", &a[i]); 9 } 10 for (int i = 1; i <= m; i++) { 11 scanf("%d", &b[i]); 12 } 13 t=0; 14 while (1) { 15 memset(c,0, sizeof(c)); 16 memset(d,0, sizeof(d)); 17 for (int i = 1; i <= n; i++) { 18 c[a[i]] = 1; 19 } 20 for (int i = 1; i <= m; i++) { 21 d[b[i] + t] = 1; 22 } 23 f=0; 24 for (int i=1;i<=1000;i++){ 25 if (c[i]&&d[i]==1){ 26 f=1; 27 break; 28 } 29 } 30 if (!f){ 31 printf("%d\n",t); 32 break; 33 } 34 t++; 35 } 36 } 37 }
1 #include <bits/stdc++.h> 2 using namespace std; 3 const int mod = 1000000007; 4 long long quickpow(long long a, long long b) { 5 if (b < 0) return 0; 6 long long ret = 1; 7 a %= mod; 8 while(b) { 9 if (b & 1) ret = (ret * a) % mod; 10 b >>= 1; 11 a = (a * a) % mod; 12 } 13 return ret; 14 } 15 long long inv(long long a) { 16 return quickpow(a, mod - 2); 17 } 18 int main() { 19 long long n; 20 scanf("%lld",&n); 21 long long ans=((n+1)*inv(2*n))%mod; 22 printf("%lld\n",ans); 23 return 0; 24 }
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 typedef long long ll; 5 ll n,b[1000],a[2000],m,lcm,x[2000],k,sum; 6 7 ll gcd(ll a,ll b){ 8 if (!b){ 9 return a; 10 } 11 return gcd(b,a%b); 12 } 13 int main() { 14 while (~scanf("%lld%lld", &n,&m)) { 15 for (int i=1;i<=n;i++){ 16 scanf("%lld",&a[i]); 17 b[a[i]]++; 18 } 19 lcm=1; 20 for (int i=1;i<=10;i++){ 21 if (b[i]){ 22 lcm=i/gcd(i,lcm)*lcm; 23 } 24 } 25 for (int i=1;i<=n;i++){ 26 x[i]=lcm/a[i]; 27 sum+=x[i]; 28 } 29 if (m%sum==0){ 30 k=m/sum; 31 printf("Yes\n"); 32 for (int i=1;i<=n;i++){ 33 printf("%lld",x[i]*k); 34 if (i==n){ 35 printf("\n"); 36 }else{ 37 printf(" "); 38 } 39 } 40 }else{ 41 printf("No\n"); 42 } 43 } 44 }
1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 int x,y; 7 scanf("%d%d",&x,&y); 8 printf("%d\n",(x*x-y*y)/4); 9 }
1 #include <bits/stdc++.h> 2 using namespace std; 3 char c[100]; 4 double ans; 5 int n,l; 6 int main() { 7 while (~scanf("%d", &n)) { 8 ans=0; 9 for (int i = 1; i <= n; i++) { 10 scanf("%s", &c); 11 l = strlen(c); 12 if (c[l - 1] < '5') { 13 ans -= 0.001 * (c[l - 1] - '0'); 14 } else { 15 ans += (10 - (c[l - 1] - '0')) * 0.001; 16 } 17 } 18 printf("%.3lf\n", ans); 19 } 20 }
1 #include<bits/stdc++.h> 2 3 using namespace std; 4 vector<int>a[105]; 5 int ans,n,c,x,s1,s2,k1,k2,sum,tmp; 6 int main() { 7 scanf("%d%d", &n, &c); 8 for (int i = 1; i <= n; i++) { 9 scanf("%d", &x); 10 a[x].push_back(i); 11 } 12 for (int i = 1; i <= c; i++) { 13 for (int j = 1; j <= c; j++) { 14 if (i != j) { 15 s1 = a[i].size(); 16 s2 = a[j].size(); 17 k1 = k2 = sum = tmp = 0; 18 while (1) { 19 while (k1 < s1 && a[i][k1] < tmp) { 20 k1++; 21 } 22 if (k1 == s1) { 23 break; 24 } 25 tmp = a[i][k1]; 26 sum++; 27 while (k2 < s2 && a[j][k2] < tmp) { 28 k2++; 29 } 30 if (k2 == s2) { 31 break; 32 } 33 tmp = a[j][k2]; 34 sum++; 35 } 36 ans = max(ans, sum); 37 } 38 } 39 } 40 printf("%d\n", ans); 41 }