随笔分类 - SDUT_ACM
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2066&cid=1158View Code #include #include long long num; int main() { int n,k,T,i ; w...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2064&cid=1158View Code #include<stdio.h> long long f(int n) { if(n==0) return 1 ; else return 3*f(n-1); } int main() { int n, t ; scanf("%d", &t) ; while(t--) { scanf("%d", &n) ; printf("...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2067&cid=1158View Code #include<stdio.h>#include<string.h>#define max(a, b) (a>b?a:b)struct node{ int len, a[1000] ;}dp[251] ;void add(node a, node b, node &c){ int i ; int len = max(a.len, b.len) ; for(i=1; i<=len; i++) c.a
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2065&cid=1158View Code #include<stdio.h>int main(){ int n, i ; int f[31] ; while(scanf("%d", &n)!=EOF) { if(n==-1) break ; f[0] = 1 ; f[2] = 3 ; for(i=4; i<=n; i=i+2) f[i] = 4*f[i-2] - f[i-4] ; ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2056&cid=1156View Code #include<stdio.h> #include<stdlib.h> struct node { int num ; struct node *next ; }; struct node *creat(int n) { int i ; struct node *head, *p, *tail ; p = (struct node*)malloc(sizeof(struct node))...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2062&cid=1157法一:用dp[i][0]、dp[i][1]表示递推到第i位时为0以及非0的情况种数进行dp。View Code #include<stdio.h>int main(){ long long dp[20][2] ; int n, k ; while(scanf("%d %d", &n, &k)!=EOF) { dp[1][1] = k-1 ; dp[1][0] = 0 ; for(int i=2; i<=n..
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1266View Code 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 long long int a[21]; 5 long long int zhan[21]; 6 int main() 7 { 8 int i,j,n,t,x; 9 long long int s; 10 scanf("%d",&
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1150View Code 1 #include<iostream> 2 #include<cmath> 3 using namespace std ; 4 int a[2000000], b[2000000] ; 5 int n ; 6 int main() 7 { 8 int i, j, t, num, q ; 9 cin>>n ;10 t = sqrt(n) ;11 num = 0 ;12 for(i=2
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1463View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 int main() 6 { 7 char c[105]; 8 int flag=0; 9 while(cin>>c)10 {11 flag=0;12 for(int i=0;i<strl..
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1485View Code 1 #include<stdio.h> 2 #include<string.h> 3 int judge(int n) 4 { 5 int a[10] ; 6 memset(a, 0, sizeof(a)) ; 7 int m = 1 ; 8 for(int i=0; i<4; i++) 9 {10 if(a[(n/m)%10]==0)11 {12 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1486&cid=1148View Code 1 #include<stdio.h> 2 int main() 3 { 4 int t, a ; 5 scanf("%d", &t) ; 6 while(t--) 7 { 8 scanf("%d", &a) ; 9 double m = 1.0*360/(180-a) ; 10 int n = 360/(180-a) ; 11 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2404&cid=1151View Code 1 #include<stdio.h> 2 #define max 100000 3 int a[max], b[max], c[max] ; 4 int main() 5 { 6 for(int i=0; i<max; i++) 7 { 8 a[i] = 1 ; 9 b[i] = 0 ; 10 } 11 a[0] = 0 ; 12 a[1...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2413&cid=1151View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 using namespace std ; 5 int main() 6 { 7 string s ; 8 int t ; 9 while(cin>>t) 10 { 11 getchar() ; 12 for(int i=1;...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1956&cid=1151floyd: 用 g++ 提交View Code 1 #include <stdio.h> 2 #include <string.h> 3 const int inf = 1<<28; 4 const int maxn = 1001; 5 int map[maxn][maxn]; 6 int n ; 7 void floyd() 8 { 9 for(int k = 1; k <= n; k++) 10 { 11 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2409View Code 1 #include<stdio.h> 2 int main() 3 { 4 int a[22][22],v[21][21],i,j,m,n,t,k,flag,mf,nf; 5 scanf("%d",&t); 6 for(k=1;k<=t;k++) 7 { 8 scanf("%d%d",&m,&n); 9 flag=0;10 for(i=
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1487View Code 1 #include <stdio.h> 2 int main() 3 { 4 int len, cnt; 5 char s[55]; 6 while(scanf("%d%s", &len, s)!=EOF) 7 { 8 char lastcolor = 0 ; 9 cnt = 0 ;10 for(int i=0;i<len;i++)11 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1476View Code 1 #include<iostream> 2 using namespace std ; 3 int main() 4 { 5 int a[10005]; 6 int n, i ; 7 while(cin>>n) 8 { 9 int sum = 0 ;10 for(i=0; i<n; i++)11 cin>>a[i] ;12 fo...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1500&cid=1147View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<malloc.h> 4 int num ; 5 struct node 6 { 7 int flag; 8 struct node *next[26]; 9 };10 struct node *creat()11 {12 int i;13 struct node *p;14 p=(struct nod..
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2137&cid=1145View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<malloc.h> 4 typedef struct tree 5 { 6 char data ; 7 struct tree *l, *r ; 8 }tree ; 9 tree *creat(char *root, char *in, int k ) 10 { 11 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2136&cid=1145View Code 1 #include<stdio.h> 2 #include<malloc.h> 3 typedef struct node 4 { 5 char data ; 6 struct node *l, *r ; 7 }tree ; 8 tree *t ; 9 tree *creat(tree *t) 10 { 11 char c ; 12 if((c = get...
阅读全文

浙公网安备 33010602011771号