题意:就算日期,给出某年某月某日星期几,问另一日期是星期几
做法:因为这个题给简化了,本来打算用基姆拉尔森公式,这个题干的话直接取日期取余5就行
代码:
//去吧马里奥!把AC公主救回来! // ******** // ************ // ####....#. // #..###.....##.... // ###.......###### // ........... // ##*####### // ####*******###### // ...#***.****.*###.... // ....**********##..... // ....**** *****.... // #### #### // ###### ###### #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<string> #include<map> #include<sstream> #include<cstring> #include<vector> #include<iomanip> #include<queue> #include<set> #define LL long long #define _64 __int64 const double PI = atan(1.)*4.; using namespace std; string day[6] = {"Friday","Monday","Tuesday","Wednesday","Thursday","Friday"}; int main(){ int t; cin >> t; while(t--){ int y1,m1,d1,dd; string s; cin >> y1 >> m1 >> d1 >> s; int i; for(i = 0; i < 5; i++){ if(s == day[i]){ dd = i; } } int y2,m2,d2; cin >> y2 >> m2 >> d2; if(d1 <= d2){ dd = (dd + (d2 - d1) %5 ) %5; }else{ dd = (dd+ 5 - (d1 - d2) %5) %5; } cout << day[dd] << endl; } }
题意:一个机器人从(0,0)开始,给出上下左右的方向,每次一步,循环k次,问最远的距离在哪里
代码:
//去吧马里奥!把AC公主救回来! // ******** // ************ // ####....#. // #..###.....##.... // ###.......###### // ........... // ##*####### // ####*******###### // ...#***.****.*###.... // ....**********##..... // ....**** *****.... // #### #### // ###### ###### #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<string> #include<map> #include<sstream> #include<cstring> #include<vector> #include<iomanip> #include<queue> #include<set> #define LL long long #define _64 __int64 const double PI = atan(1.)*4.; using namespace std; int main(){ int t; cin >> t; while(t--){ LL n,k; string s; cin >> n >> k >> s; LL x = 0,y = 0; LL num = 0; for(int i = 0;i < n;i++){ if(s[i] == ‘U‘){ y++; }else if(s[i] == ‘D‘){ y--; }else if(s[i] == ‘L‘){ x--; }else if(s[i] == ‘R‘){ x++; } if(num < abs(x)+abs(y)){ num = abs(x)+abs(y); } } x = x * (k-1); y = y * (k-1); for(int i = 0;i < n;i++){ if(s[i] == ‘U‘){ y++; }else if(s[i] == ‘D‘){ y--; }else if(s[i] == ‘L‘){ x--; }else if(s[i] == ‘R‘){ x++; } if(num < abs(x)+abs(y)){ num = abs(x)+abs(y); } } cout << num << endl; } }
做法:n个节点的话,每个节点都连接最少需要n-1条边,求m-(n-1)再取余人数就行
代码:
//去吧马里奥!把AC公主救回来! // ******** // ************ // ####....#. // #..###.....##.... // ###.......###### // ........... // ##*####### // ####*******###### // ...#***.****.*###.... // ....**********##..... // ....**** *****.... // #### #### // ###### ###### #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<string> #include<map> #include<sstream> #include<cstring> #include<vector> #include<iomanip> #include<queue> #include<set> #define LL long long #define _64 __int64 const double PI = atan(1.)*4.; using namespace std; char a[200005]; int main(){ int t; cin >> t; while(t--){ int k; cin >> k; for(int i = 0;i < k;i++){ cin >> a[i]; } int n,m; cin >> n >>m; int d1,d2; for(int i = 0;i < m;i++){ cin >> d1 >> d2; } m = (m-(n-1))%k; if(a[m] == ‘1‘){ cout << 2 << endl; }else{ cout << 1 << endl; } } }
题意:一堆桶,里面有石子,可以从有石子的桶里往外拿石子,也可以把石子扔了,问要使每个桶的石子数一样,求最少的步数
做法:把所有桶的石子平均一下就可以,先求平均值,之后余数肯定要扔掉了,之后只需要算比平均数多的桶的石子有多少就行
代码:
//去吧马里奥!把AC公主救回来! // ******** // ************ // ####....#. // #..###.....##.... // ###.......###### // ........... // ##*####### // ####*******###### // ...#***.****.*###.... // ....**********##..... // ....**** *****.... // #### #### // ###### ###### #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<string> #include<map> #include<sstream> #include<cstring> #include<vector> #include<iomanip> #include<queue> #include<set> #define LL long long #define _64 __int64 const double PI = atan(1.)*4.; using namespace std; LL a[200005]; int main(){ int t; cin >> t; while(t--){ LL n; cin >> n; LL sum = 0; for(int i = 0;i < n;i++){ cin >> a[i]; sum += a[i]; } sum = sum / n; LL ans = 0; for(int i = 0;i < n;i++){ if(a[i] > sum){ ans += a[i]-sum; } } cout << ans << endl; } }
题意:带了一些金币,死一次变成原来的一半,问死了一些次之后还剩多少金币
做法:需要向上取整,不知道为啥ceil()会超时,最后用的+1做的
//去吧马里奥!把AC公主救回来! // ******** // ************ // ####....#. // #..###.....##.... // ###.......###### // ........... // ##*####### // ####*******###### // ...#***.****.*###.... // ....**********##..... // ....**** *****.... // #### #### // ###### ###### #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<string> #include<map> #include<sstream> #include<cstring> #include<vector> #include<iomanip> #include<queue> #include<set> #define LL long long #define _64 __int64 const double PI = atan(1.)*4.; using namespace std; int main(){ int t; cin >> t; while(t--){ int n,k; cin >> n >> k; for(int i = 0;i < k;i++){ if(n == 0){ break; }else if(n == 1){ break; }else{ n = (n+1) / 2; } } cout << n << endl; } }
当天没打,现在才吐血补完,u1s1要是读题真的是一个大问题,光读题就能让人不想打,但题目写起来还是不难的,但是需要脑子活泛些,还有一些数论啥的题,相关知识不熟悉没有补,总之……继续努力吧
原文:https://www.cnblogs.com/CCCCrack/p/13758940.html