网友投稿 880 2022-09-02
训练赛总结
A(HDU 1877)
题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;void huang(unsigned long long a,int k){ if(a == 0) return; huang(a/k,k); printf("%I64d",a%k);}int main(){ int m,a,b; while(scanf("%d",&m) && m) { scanf("%d%d",&a,&b); unsigned long long sum; sum = (LL)(a + b); if(sum == 0) { printf("0\n"); continue; } huang(sum,m); printf("\n"); } return 0;}
B(HDU 1878)
题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int visit[1010];int pre[1010];int fin(int x){ return pre[x] == x ? x : pre[x] = fin(pre[x]);}void union1(int a,int b){ int fa = fin(a); int fb = fin(b); if(fa != fb) { pre[fa] = fb; }}int main(){ int n,m; while(scanf("%d",&n) && n) { memset(visit,0,sizeof(visit)); scanf("%d",&m); int a,b,i; for(i=1; i<=n; i++) { pre[i] = i; } for(i=0; iC(HDU 1879)思路:建成的路花费标记为0,跑最短路D(HDU 1880)题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;char a[25],b[85];char c[110];int main(){ map map1; while(true) { gets(c); if(strcmp(c,"@END@") == 0) break; int len = strlen(c); int k = 0; int f = 0; while(c[f] != ']') { a[k++] = c[f]; f++; } a[k++] = ']'; a[k] = '\0'; int m = 0; for(int i=f+2; i::iterator it; for(int i=0; i超时代码2:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;char a[25],b[85];char c[110];int main(){ map map1; while(true) { gets(c); if(strcmp(c,"@END@") == 0) break; int len = strlen(c); int k = 0; int f = 0; while(c[f] != ']') { a[k++] = c[f]; f++; } a[k++] = ']'; a[k] = '\0'; int m = 0; for(int i=f+2; i::iterator it; for(int i=0; iE(HDU 1881)题目地址:1798)题目地址:(HDU 1795)题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;bool isprime[11000];void doprime(){ memset(isprime,true,sizeof(isprime)); for(int i=2; i<=1000; i++) { if(isprime[i]) { for(int j=i*i; j<=11000; j+=i) { isprime[j] = false; } } }}int main(){ doprime(); int t; scanf("%d",&t); while(t--) { int k; scanf("%d",&k); k++; while(true) { if(isprime[k]) { printf("%d\n",k); break; } k++; } } return 0;}I(HDU 1794)题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int map1[35][35][35];int b[1000],c[10010];bool cmp(int a,int b){ return a > b;}int main(){ memset(map1,0,sizeof(map1)); for(int f=1; f<=30; f++) { for(int i=1; i<=f; i++) { for(int j=1; j<=f; j++) { for(int k=0; k<=min(f-i,f-j); k++) { for(int l=i; l<=i+k; l++) { for(int m=j; m<=j+k; m++) { map1[f][l][m]++; } } } } } } int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int k = 0; for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { int x; scanf("%d",&x); if(x == 0) b[k++] = map1[n][i][j]; } } int m; scanf("%d",&m); for(int i=0; i 版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
C(HDU 1879)
思路:建成的路花费标记为0,跑最短路
D(HDU 1880)
题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;char a[25],b[85];char c[110];int main(){ map map1; while(true) { gets(c); if(strcmp(c,"@END@") == 0) break; int len = strlen(c); int k = 0; int f = 0; while(c[f] != ']') { a[k++] = c[f]; f++; } a[k++] = ']'; a[k] = '\0'; int m = 0; for(int i=f+2; i::iterator it; for(int i=0; i超时代码2:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;char a[25],b[85];char c[110];int main(){ map map1; while(true) { gets(c); if(strcmp(c,"@END@") == 0) break; int len = strlen(c); int k = 0; int f = 0; while(c[f] != ']') { a[k++] = c[f]; f++; } a[k++] = ']'; a[k] = '\0'; int m = 0; for(int i=f+2; i::iterator it; for(int i=0; iE(HDU 1881)题目地址:1798)题目地址:(HDU 1795)题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;bool isprime[11000];void doprime(){ memset(isprime,true,sizeof(isprime)); for(int i=2; i<=1000; i++) { if(isprime[i]) { for(int j=i*i; j<=11000; j+=i) { isprime[j] = false; } } }}int main(){ doprime(); int t; scanf("%d",&t); while(t--) { int k; scanf("%d",&k); k++; while(true) { if(isprime[k]) { printf("%d\n",k); break; } k++; } } return 0;}I(HDU 1794)题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int map1[35][35][35];int b[1000],c[10010];bool cmp(int a,int b){ return a > b;}int main(){ memset(map1,0,sizeof(map1)); for(int f=1; f<=30; f++) { for(int i=1; i<=f; i++) { for(int j=1; j<=f; j++) { for(int k=0; k<=min(f-i,f-j); k++) { for(int l=i; l<=i+k; l++) { for(int m=j; m<=j+k; m++) { map1[f][l][m]++; } } } } } } int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int k = 0; for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { int x; scanf("%d",&x); if(x == 0) b[k++] = map1[n][i][j]; } } int m; scanf("%d",&m); for(int i=0; i 版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
超时代码2:
#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;char a[25],b[85];char c[110];int main(){ map map1; while(true) { gets(c); if(strcmp(c,"@END@") == 0) break; int len = strlen(c); int k = 0; int f = 0; while(c[f] != ']') { a[k++] = c[f]; f++; } a[k++] = ']'; a[k] = '\0'; int m = 0; for(int i=f+2; i::iterator it; for(int i=0; iE(HDU 1881)题目地址:1798)题目地址:(HDU 1795)题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;bool isprime[11000];void doprime(){ memset(isprime,true,sizeof(isprime)); for(int i=2; i<=1000; i++) { if(isprime[i]) { for(int j=i*i; j<=11000; j+=i) { isprime[j] = false; } } }}int main(){ doprime(); int t; scanf("%d",&t); while(t--) { int k; scanf("%d",&k); k++; while(true) { if(isprime[k]) { printf("%d\n",k); break; } k++; } } return 0;}I(HDU 1794)题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int map1[35][35][35];int b[1000],c[10010];bool cmp(int a,int b){ return a > b;}int main(){ memset(map1,0,sizeof(map1)); for(int f=1; f<=30; f++) { for(int i=1; i<=f; i++) { for(int j=1; j<=f; j++) { for(int k=0; k<=min(f-i,f-j); k++) { for(int l=i; l<=i+k; l++) { for(int m=j; m<=j+k; m++) { map1[f][l][m]++; } } } } } } int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int k = 0; for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { int x; scanf("%d",&x); if(x == 0) b[k++] = map1[n][i][j]; } } int m; scanf("%d",&m); for(int i=0; i 版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
E(HDU 1881)
题目地址:1798)
题目地址:(HDU 1795)
题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;bool isprime[11000];void doprime(){ memset(isprime,true,sizeof(isprime)); for(int i=2; i<=1000; i++) { if(isprime[i]) { for(int j=i*i; j<=11000; j+=i) { isprime[j] = false; } } }}int main(){ doprime(); int t; scanf("%d",&t); while(t--) { int k; scanf("%d",&k); k++; while(true) { if(isprime[k]) { printf("%d\n",k); break; } k++; } } return 0;}
I(HDU 1794)
题目地址:#include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int map1[35][35][35];int b[1000],c[10010];bool cmp(int a,int b){ return a > b;}int main(){ memset(map1,0,sizeof(map1)); for(int f=1; f<=30; f++) { for(int i=1; i<=f; i++) { for(int j=1; j<=f; j++) { for(int k=0; k<=min(f-i,f-j); k++) { for(int l=i; l<=i+k; l++) { for(int m=j; m<=j+k; m++) { map1[f][l][m]++; } } } } } } int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int k = 0; for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { int x; scanf("%d",&x); if(x == 0) b[k++] = map1[n][i][j]; } } int m; scanf("%d",&m); for(int i=0; i 版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~
暂时没有评论,来抢沙发吧~