速通51题解
2024-05-08 13:18:47
发布于:广东
T1 A + B + C
T2 2的N次方
T3 下一个字母
T4 千位分割符
T5 画个ACGO
T6 音乐播放器
T7 10的N次方
T8 日期间隔计算
T9 ZXC的闯关计划
T10 2024的倍数
代码摆这了,要讲解看题解(除T1太简单)
T1
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main(){
int a, b, c;
cin >> a >> b >> c;
cout << a + b + c;
return 0;
}
T2
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main(){
long long x = 1;
int n;
cin >> n;
cout << (x << n);
return 0;
}
T3
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main(){
string a;
cin >> a;
for(int i = 0; a[i] != '\0'; i++){
if('a' <= a[i] && a[i] <= 'z'){
if(a[i] == 'z') a[i] = 'a';
else a[i]++;
}else if(a[i] >= 'A'){
if(a[i] == 'Z') a[i] = 'A';
else a[i]++;
}
}cout << a;
return 0;
}
T4
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
void fenge(int n){
if(n < 1000){
cout << n;
return;
}fenge(n / 1000);
printf(",%03d", n % 1000);
}
int main(){
int n;
cin >> n;
fenge(n);
return 0;
}
T5
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main(){
cout << R"( ___ ______ _______ ______
/ \ / | / _____| / __ \
/ ^ \ | ,----'| | __ | | | |
/ /_\ \ | | | | |_ | | | | |
/ _____ \ | `----.| |__| | | `--' |
/__/ \__\ \______| \______| \______/)";
return 0;
}
T6
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int n, m, k;
cin >> n >> m >> k;
string a;
while(m--){
cin >> a;
if(a == "<-") k--;
else k++;
}
if(k % n == 0) cout << n;
else cout << k % n;
return 0;
}
T7
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main(){
int n;
cin >> n;
cout << 1;
while(n--) cout << 0;
return 0;
}
T8
#include <iostream>
#include <cstdio>
using namespace std;
int mth[] = {0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n1, m1, k1, n2, m2, k2;
bool check(int x){
return x % 400 == 0 || x % 4 == 0 && x % 100;
}void s(){
swap(n1, n2), swap(m1, m2), swap(k1, k2);
}
int main(){
scanf("%d-%d-%d %d-%d-%d", &n1, &m1, &k1, &n2, &m2, &k2);
if(n1 > n2){
s();
}else if(n1 == n2 && m1 > m2){
s();
}else if(n1 == n2 && m1 == m2 && k1 > k2){
s();
}int ct = 0;
while(n1 != n2 || m1 != m2 || k1 != k2){
if(check(n1)) mth[2] = 29;
else mth[2] = 28;
k1++, ct++;
if(k1 > mth[m1]) m1++, k1 = 1;
if(m1 >= 13) n1++, m1 = 1;
}cout << ct;
return 0;
}
T9
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100005];
int main(){
long long n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i];
}sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i++){
if(m <= a[i]){
cout << -1;
return 0;
}m -= a[i];
m *= 1.02;
}
cout << m;
return 0;
}
T10
#include <iostream>
#include <cstdio>
using namespace std;
long long bucket[100005];
int main(){
int n, x;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x;
bucket[x % 2024]++;
}long long ct = 0;
for(int i = 0; i <= 2023; i++){
ct += bucket[i] * (bucket[i] - 1) / 2;
}cout << ct;
return 0;
}
全部评论 4
顶!
2024-05-07 来自 广东
0输了
2024-05-07 来自 广东
0
9
2024-05-07 来自 广东
0?怎么沉下去了
2024-05-06 来自 广东
06
2024-05-06 来自 广东
0
有帮助,赞一个