2021寒假训练(四)
| 题号 | A | B | C | D | E | F | G | H |
| AC | √ | √ | √ | √ |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 2e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1e9 + 7; #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } signed main(){ int n,m; while(~scanf("%lld %lld",&n,&m)){ double res = 0; for(int i = 0; i < n; i++){ double x; scanf("%lf",&x); res+=0.5*sin((x/180.0)*PI)*(m * m * 1.0); } printf("%.3lf\n",res); } //system("pause"); return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 2e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1e9 + 7; #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}}; signed main(){ int T = rd(); while(T--){ int n,m,mp[60][60]={0},res = 0; n = rd(); m = rd(); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ mp[i][j] = rd(); } } for(int i = 1; i <= n ; i++){ for(int j = 1; j <= m; j++){ if(mp[i][j] != 0){ res++; for(int k = 0; k<4; k++){ int nx = i + dir[k][0]; int ny = j + dir[k][1]; if(mp[i][j] > mp[nx][ny]){ res += (mp[i][j] - mp[nx][ny]); } } } // printf("%lld %lld %lld\n",i,j,cnt); } } printf("%lld\n",res); } //system("pause"); return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 2e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1e9 + 7; #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } int even[maxn],odd[maxn]; signed main(){ int T = rd(); while(T--){ int n = rd(); int cnt_even = 0; int cnt_odd = 0; for(int i = 0; i < n; i++){ int m = rd(); if(m % 2 == 0)even[cnt_even++] = m; else odd[cnt_odd++] = m; } // if(cnt_even > cnt_odd){ // for(int i = cnt_odd; i < cnt_even; i++)odd[i]=0; // cnt_odd = cnt_even; // }else if(cnt_even < cnt_odd){ // for(int i = cnt_even; i< cnt_odd; i++)even[i]=0; // cnt_even = cnt_odd; // } sort(even, even + cnt_even, greater<int>()); sort(odd, odd + cnt_odd,greater<int>()); int resA = 0, resB = 0; int pe = 0, po = 0; while(pe<cnt_even || po<cnt_odd){ int x = 0, y = 0; if(pe < cnt_even)x = even[pe]; if(po < cnt_odd)y = odd[po]; if(x > y){ pe++; resA += x; }else{ po++; } x = 0,y = 0; if(pe < cnt_even)x = even[pe]; if(po < cnt_odd)y = odd[po]; if(x < y){ po++; resB += y; }else{ pe++; } } if(resA > resB)printf("Alice\n"); else if(resA < resB)printf("Bob\n"); else printf("Tie\n"); } //system("pause"); return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 2e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1e9 + 7; #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } int a[maxn],sum[maxn]; signed main(){ int t = rd(); while(t--){ int n = rd(); int Max = -1; for(int i = 1; i <= n; i++){ a[i] = rd(); } for(int i = n; i >= 1; i--){ if(a[i] + i <= n)a[i] = a[a[i]+i]+a[i]; if(a[i] > Max)Max = a[i]; } printf("%lld\n",Max); } //system("pause"); return 0; }

浙公网安备 33010602011771号