├── UVa - 100 - me again.cpp ├── UVa - 10055 - anis bhai.c ├── UVa - 10071.c ├── UVa - 10079 - cutting pizza.cpp ├── UVa - 10226.cpp ├── UVa - 10327.cpp ├── UVa - 10349 - Peter's Smoke.cpp ├── UVa - 10370.cpp ├── UVa - 10394 - twin prime.cpp ├── UVa - 10424.cpp ├── UVa - 10924 - Prime Words.cpp ├── UVa - 10948 - The primary problem.cpp ├── UVa - 11172.c ├── UVa - 113.cpp ├── UVa - 11455.cpp ├── UVa - 11727.c ├── UVa - 11877 - The Coco-Cola Store.cpp ├── UVa - 12356 - online.cpp ├── UVa - 12372.c ├── UVa - 12646 - Zero or One.cpp ├── UVa - 136.cpp ├── UVa - 231.cpp ├── UVa - 280 - vertex.cpp ├── UVa - 406 - Prime Cuts.cpp ├── UVa - 458.cpp ├── UVa - 484.cpp ├── UVa - 543 .cpp ├── codeforces - 112A.cpp ├── codeforces - 116A.cpp ├── codeforces - 118A.cpp ├── codeforces - 122A.cpp ├── codeforces - 155A.cpp ├── codeforces - 158A.c ├── codeforces - 158A.cpp ├── codeforces - 231A.cpp ├── codeforces - 263A.cpp ├── codeforces - 282A.cpp ├── codeforces - 339A.cpp ├── codeforces - 379A.cpp ├── codeforces - 451A.c ├── codeforces - 467B.cpp ├── codeforces - 50A.cpp ├── codeforces - 546A.cpp ├── codeforces - 622B.cpp ├── codeforces - 69A.cpp ├── codeforces - 714A.cpp ├── codeforces - 71A.c ├── codeforces - 71A.cpp ├── codemarshal - Celebrating Victory.c ├── codemarshal - area of triangle.c ├── codemarshal - average mark.c ├── codemarshal - grading method.c ├── codemarshal - maximum number.c ├── codemarshal - multiplication table.c ├── codemarshal - pyramid of number - shoib.c ├── codemarshal - pyramid of number.c ├── codemarshal - pyramid of stars.c ├── codemarshal - series of number.c └── codemarshal - series of numbers - i for shoib.c /UVa - 100 - me again.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /*#include 4 | #define long long LL 5 | */ 6 | using namespace std; 7 | 8 | int cal(unsigned int n){ 9 | int cycle_length = 1; 10 | while ( n != 1 ) { 11 | if ( n % 2 == 1 ) n = 3 * n + 1; 12 | else n /= 2; 13 | cycle_length++; 14 | } 15 | return cycle_length; 16 | } 17 | 18 | int main () 19 | { 20 | int i, j; 21 | while(cin>>i>>j){ 22 | int temp_i = i; 23 | int temp_j = j; 24 | if(i>j) swap(i, j); 25 | int max_cycle_length = 0; 26 | int cycle_length; 27 | while(i<=j) { 28 | unsigned int n = i; 29 | // calling function 30 | cycle_length = cal(n); 31 | if(cycle_length > max_cycle_length) max_cycle_length = cycle_length; 32 | i++; 33 | } 34 | // printing the output 35 | cout << temp_i << " " << temp_j << " " << max_cycle_length << endl; 36 | } 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /UVa - 10055 - anis bhai.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | long int h, o; 6 | 7 | while(scanf("%ld %ld", &h, &o)!=EOF) { 8 | if(o>h) printf("%ld\n", o-h); 9 | else printf("%ld\n", h-o); 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /UVa - 10071.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int t, v; 6 | 7 | while(scanf("%d %d", &t, &v)!=EOF) 8 | { 9 | printf("%d\n", 2*v*t); 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /UVa - 10079 - cutting pizza.cpp: -------------------------------------------------------------------------------- 1 | // a(n) = 1 + (n(n+1))/2 formula 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main(){ 8 | long long int n; 9 | while(cin>>n){ 10 | if(n<0){ 11 | break; 12 | } 13 | else{ 14 | cout << 1 + ((n*(n+1))/2) << endl; 15 | } 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /UVa - 10226.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | /* 9 | UVa 10226 10 | Hardwood Species 11 | */ 12 | 13 | int main(){ 14 | int test; 15 | scanf("%d\n\n", &test); 16 | //getchar(); 17 | while(test--){ 18 | maplogBook; 19 | int total=0; 20 | char name[35]; 21 | while(gets(name)){ 22 | if(strlen(name)==0) break; 23 | if(logBook.count(string(name))==0){ 24 | logBook[string(name)] = 1; 25 | } 26 | else{ 27 | logBook[string(name)]+=1; 28 | } 29 | total++; 30 | } 31 | //cout << total << endl; 32 | map::iterator it; 33 | for(it=logBook.begin(); it != logBook.end(); it++){ 34 | //cout << (*it).first << " " << (float(100)/float(total))*float((*it).second) << endl; 35 | printf("%s %.4f\n", (*it).first.data(), (float(100)/float(total))*float((*it).second)); 36 | } 37 | if(test>0) printf("\n"); 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /UVa - 10327.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | while(cin>>n){ 8 | int data[n]; 9 | int m=0; 10 | // input values 11 | for(int i=0; i> data[i]; 13 | } 14 | // sorting values 15 | for (int i = 0; i < n-1; i++){ 16 | for (int j = 0; j < n-i-1; j++){ 17 | if (data[j] > data[j+1]){ 18 | int temp=data[j]; 19 | data[j]=data[j+1]; 20 | data[j+1]=temp; 21 | m++; 22 | } 23 | } 24 | } 25 | cout << "Minimum exchange operations : " << m << endl; 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /UVa - 10349 - Peter's Smoke.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n, k; 7 | while(cin>>n>>k){ 8 | int total = n; 9 | while(n>=k){ 10 | n=n-k; 11 | total++; 12 | n++; 13 | } 14 | cout << total << endl; 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /UVa - 10370.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int test; 7 | scanf("%d", &test); 8 | while(test--){ 9 | //printf("Checking\n"); 10 | int n; 11 | scanf("%d", &n); 12 | int grade[n]; 13 | double totalGrade=0; 14 | for(int i=0; iavgGrade) aboveAvg++; 24 | } 25 | //printf("%d\n", aboveAvg); 26 | printf("%.3lf%%\n", (double(aboveAvg)/double(n))*100); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /UVa - 10394 - twin prime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define M 20000001 5 | 6 | using namespace std; 7 | 8 | int prime[M]={0}; 9 | vectorprimeNumber; 10 | 11 | void primeGenerate(){ 12 | for(int i=2; i<=M; i++){ 13 | if(prime[i]==0){ 14 | prime[i]=-1; 15 | //primeNumber.push_back(i); 16 | for(int j=i+i; j 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int calValue(char n[]){ 8 | int value=0; 9 | for(int i=0; i=97 && n[i]<=122) value=value+n[i]-96; 11 | else if(n[i]>=65 && n[i]<=90) value=value+n[i]-64; 12 | } 13 | return value; 14 | } 15 | 16 | int conValue(int n){ 17 | if(n<10) return n; 18 | else conValue((n%10)+(n/10)); 19 | } 20 | 21 | /* 22 | n = 77 23 | n = (n%10) + (n/10) 24 | n = 7 + 7 25 | n = 14 26 | n = 4 + 1 27 | n = 5 28 | */ 29 | 30 | int main(){ 31 | char n1[27], n2[27]; 32 | while(gets(n1)){ 33 | gets(n2); 34 | //puts(n1); 35 | //puts(n2); 36 | int n1Value = calValue(n1); 37 | int n2Value = calValue(n2); 38 | int n1Con = conValue(n1Value); 39 | int n2Con = conValue(n2Value); 40 | //cout << n1Value << endl << n2Value << endl; 41 | //cout << n1Con << endl << n2Con << endl; 42 | if(n1Con==n2Con) printf("100.00 %%\n"); 43 | else if(n1Con>n2Con) printf("%.2lf %%\n", double(double(n2Con)/double(n1Con))*100); 44 | else if(n1Con 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int primeWordValue(char word[], int n){ 8 | int number=0; 9 | for(int i=0; i='a' && word[i]<='z') number+=toascii(word[i])-96; 11 | else number+=toascii(word[i])-38;; 12 | } 13 | return number; 14 | } 15 | 16 | bool checkPrime(int n){ 17 | bool status = true; 18 | for(int i=2; i 2 | #include 3 | #define M 1000001 4 | 5 | using namespace std; 6 | 7 | int prime[M]={0}; 8 | vectorprimeNumber; 9 | 10 | void primeGen(){ 11 | for(int i=2; i<=M; i++){ 12 | if(prime[i]==0){ 13 | prime[i]=-1; 14 | primeNumber.push_back(i); 15 | for(int j=i+i; j 2 | 3 | int main() 4 | { 5 | int t, i, a, b; 6 | scanf("%d", &t); 7 | for(i=1; i<=t; i++) 8 | { 9 | scanf("%d %d", &a, &b); 10 | if(a>b) printf(">\n"); 11 | else if(a 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | double n, p; 7 | while(scanf("%lf %lf", &n, &p)!=EOF) 8 | printf("%.0lf\n", pow(p, (1/n))); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /UVa - 11455.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // UVa 11455 6 | // Behold my quadrangle 7 | 8 | int main(){ 9 | int test; 10 | scanf("%d", &test); 11 | for(int i=1; i<=test; i++){ 12 | int a, b, c, d; 13 | scanf("%d %d %d %d", &a, &b, &c, &d); 14 | if(a==b && b==c && c==d && d==a) printf("square\n"); 15 | else if((a==c && b==d)||(a==b && c==d)||(b==c && a==d)) printf("rectangle\n"); 16 | else if(a<=b+c+d && b<=a+c+d && c<=a+b+d && d<=a+b+c) printf("quadrangle\n"); 17 | else printf("banana\n"); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /UVa - 11727.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int t, i, a, b, c; 6 | scanf("%d", &t); 7 | for(i=1; i<=t; i++) 8 | { 9 | scanf("%d %d %d", &a, &b, &c); 10 | if((a>b && ac)) 11 | printf("Case %d: %d\n", i, a); 12 | else if((b>a && bc)) 13 | printf("Case %d: %d\n", i, b); 14 | else printf("Case %d: %d\n", i, c); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /UVa - 11877 - The Coco-Cola Store.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | /* 8 | UVa - 11877 - The Coco-Cola Store 9 | */ 10 | 11 | int main(){ 12 | int n; 13 | while(scanf("%d", &n)){ 14 | if(n==0) break; 15 | else{ 16 | float d=((float)(n*3)-1)/2; 17 | int cola=ceil(d); 18 | printf("%d\n", cola-n); 19 | } 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /UVa - 12356 - online.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int left[100005], right[100005]; 6 | 7 | int main() { 8 | int s, b; 9 | while (scanf("%d %d", &s, &b)) { 10 | if(s==0 && b==0) break; 11 | for (int i = 1; i <= s; i++) { 12 | left[i] = i - 1; 13 | right[i] = i + 1; 14 | } 15 | right[s] = -1; 16 | left[1] = -1; 17 | int l, r; 18 | for (int i = 0; i < b; i++) { 19 | scanf("%d %d", &l, &r); 20 | left[right[r]] = left[l]; 21 | if (left[l] != -1) printf("%d", left[l]); 22 | else printf("*"); 23 | right[left[l]] = right[r]; 24 | if (right[r] != -1) printf(" %d\n", right[r]); 25 | else printf(" *\n"); 26 | } 27 | printf("-\n"); 28 | } 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /UVa - 12372.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a, b, c, i, n; 6 | scanf("%d", &n); 7 | for(i=1; i<=n; i++) 8 | { 9 | scanf("%d %d %d", &a, &b, &c); 10 | if(a<=20 && b<=20 && c<=20) 11 | printf("Case %d: good\n", i); 12 | else printf("Case %d: bad\n", i); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /UVa - 12646 - Zero or One.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(){ 7 | int a, b, c; 8 | while(scanf("%d %d %d", &a, &b, &c)!=EOF){ 9 | if(a==b && b==c) printf("*\n"); 10 | else if(a!=b && b==c) printf("A\n"); 11 | else if(b!=a && a==c) printf("B\n"); 12 | else if(c!=b && a==b) printf("C\n"); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /UVa - 136.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | printf("The 1500'th ugly number is 859963392.\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /UVa - 231.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define M 1001 5 | 6 | using namespace std; 7 | 8 | /* 9 | UVa 230 10 | Testing the CATCHER 11 | Problem type: Longest Decreasing Subsequence 12 | */ 13 | 14 | int main(){ 15 | int data[M]; 16 | int LDS[M]; 17 | int test=0; 18 | bool isItFirst=false; 19 | while(scanf("%d", &data[0])){ 20 | int index=0; 21 | if(data[0]==-1) break; 22 | if(isItFirst) printf("\n"); 23 | isItFirst = true; 24 | while(scanf("%d", &data[++index])){ 25 | if(data[index]==-1) break; 26 | } 27 | // checking input is working 28 | /* 29 | for(int i=0; i=0; j--){ 38 | if(data[j] > data[i]){ 39 | if(LDS[i] < LDS[j]+1){ 40 | LDS[i]=LDS[j]+1; 41 | } 42 | } 43 | } 44 | } 45 | printf("Test #%d:\n maximum possible interceptions: %d\n", ++test, *max_element(LDS, LDS+index)); 46 | } 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /UVa - 280 - vertex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | /* UVa 280 */ 7 | /* Vertex */ 8 | 9 | // global declaration 10 | int n; // number of node 11 | vectorgraph[101]; // declaring graph 12 | bool visited[101] = {false}; // checking is visited or not 13 | 14 | // checking graph input 15 | void checkingInput(){ 16 | for(int i=1; i<=n; i++){ 17 | for(int j=0; jtemp; 52 | for(int i=1; i<=n; i++){ 53 | if(!visited[i]){ 54 | temp.push_back(i); 55 | } 56 | } 57 | printf("%d", temp.size()); 58 | vector::iterator t; 59 | for(t=temp.begin(); t!=temp.end(); t++) printf(" %d", *t); 60 | printf("\n"); 61 | } 62 | } 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /UVa - 406 - Prime Cuts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define M 1001 5 | 6 | using namespace std; 7 | 8 | int prime[M] = {0}; 9 | vectorprimeNumber; 10 | 11 | void primeNumGen(){ 12 | primeNumber.push_back(1); 13 | for(int i=2; i<=M; i++){ 14 | if(prime[i]==0){ 15 | primeNumber.push_back(i); 16 | for(int j=i+i; jn) break; 27 | else noPrime++; 28 | } 29 | return noPrime; 30 | } 31 | 32 | int main(){ 33 | primeNumGen(); 34 | int n, c; 35 | while(scanf("%d %d", &n, &c)==2){ 36 | printf("%d %d:", n, c); 37 | int noPrime = sizeChecker(n); 38 | //printf(" %d\n", noPrime); 39 | int startLoop; 40 | int endLoop=(noPrime/2)+(c-1); 41 | if(noPrime<=2*c){ 42 | startLoop=0; 43 | endLoop=noPrime-1; 44 | } 45 | else if(noPrime%2==0) startLoop=(noPrime/2)-c; 46 | else startLoop=(noPrime/2)-(c-1); 47 | //cout << startLoop << " " << endLoop << endl; 48 | for(int i=startLoop; i<=endLoop; i++){ 49 | printf(" %d", primeNumber[i]); 50 | } 51 | printf("\n\n"); 52 | } 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /UVa - 458.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | string inputWord; 7 | while(cin>>inputWord){ 8 | for(int i=0; i 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main(){ 9 | mapm; 10 | vectorv; 11 | int n; 12 | while(scanf("%d", &n)!=EOF){ 13 | if(m.count(n)==0){ 14 | m[n]=1; 15 | v.push_back(n); 16 | } 17 | else{ 18 | m[n]+=1; 19 | } 20 | } 21 | //map:: iterator it; 22 | //cout << v.size() << endl; 23 | //for(it=m.begin(); it != m.end(); it++) cout << (*it).first << " " << (*it).second << endl; 24 | //cout << v.size() << endl; 25 | for(int i=0; i 2 | #include 3 | #define M 1000001 4 | 5 | using namespace std; 6 | 7 | int prime[M] = {0}; 8 | vectorprimeNumber; 9 | 10 | void primeNumGen(){ 11 | for(int i=2; i<=M; i++){ 12 | if(prime[i]==0){ 13 | prime[i]=-1; 14 | primeNumber.push_back(i); 15 | for(int j=i+i; j 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(){ 7 | string a, b; 8 | cin >> a >> b; 9 | int len = a.length(); 10 | for(int i=0; i=65 && a[i]<=90) a[i]=a[i]+32; 12 | if(b[i]>=65 && b[i]<=90) b[i]=b[i]+32; 13 | } 14 | //cout << a << endl << b << endl; 15 | int value; 16 | int flag = 0; 17 | for(int i=0; i0) flag = flag + 1; 20 | else if(value<0) flag = flag - 1; 21 | else if(value==0) flag = flag + 0; 22 | if(flag!=0) break; 23 | //cout << "Diff: " << value << endl; 24 | } 25 | if(flag==0) cout << "0" << endl; 26 | else if(flag>0) cout << "1" << endl; 27 | else if(flag<0) cout << "-1" << endl; 28 | //cout << flag << endl; 29 | //cout << value << endl; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /codeforces - 116A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int stop; 7 | cin >> stop; 8 | int max_pass=0; 9 | int pass=0; 10 | int pass_in, pass_out; 11 | for(int i=0; i> pass_out >> pass_in; 13 | pass = (pass - pass_out) + pass_in; 14 | if(pass>=max_pass) max_pass = pass; 15 | } 16 | cout << max_pass << endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /codeforces - 118A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | string word; 7 | cin >> word; 8 | int len = word.length(); 9 | //cout << len; 10 | for(int i=0; i 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin >> n; 8 | int lucky[] = {4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777}; 9 | int counter = 0; 10 | for(int i=0; i<14; i++){ 11 | if(n%lucky[i]==0) counter = 1; 12 | } 13 | if(counter!=0) cout << "YES" << endl; 14 | else cout << "NO" << endl; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /codeforces - 155A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int i, n, max_num, min_num, amazing_performance = 0; 7 | cin >> n; 8 | int point[n]; 9 | /*for(i=0; i> point[i]; 11 | if(i==0){ 12 | max_num = point[i]; 13 | min_num = point[i]; 14 | } 15 | if(point[i]>max_num){ 16 | amazing_performance++; 17 | max_num = point[i]; 18 | } 19 | if(point[i]> point[i]; 25 | max_num = point[0]; 26 | min_num = point[0]; 27 | for(i=0; imax_num){ 29 | amazing_performance++; 30 | max_num = point[i]; 31 | } 32 | if(point[i] 2 | 3 | int main(){ 4 | int n, k, i, counter, score[51]; 5 | while(scanf("%d %d", &n, &k)!=EOF){ 6 | counter=0; 7 | for(i=0; i=score[k-1] && score[i]>0) counter++; 12 | } 13 | printf("%d\n", counter); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /codeforces - 158A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n, k; 7 | int score[51]; 8 | int counter=0; 9 | cin >> n >> k; 10 | for(int i=0; i> score[i]; 12 | } 13 | for(int i=0; i=score[k-1] && score[i]>0) counter++; 15 | } 16 | cout << counter << endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /codeforces - 231A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n, i, counter=0; 7 | int p, v, t; 8 | cin >> n; 9 | for(i=0; i> p >> v >> t; 11 | if((p!=0 && v!=0) || (p!=0 && t!=0) || (v!=0 && t!=0)) counter++; 12 | } 13 | cout << counter << endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /codeforces - 263A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(){ 7 | int matrix[5][5]; 8 | int i, j; 9 | for(i=0; i<5; i++){ 10 | for(j=0; j<5; j++){ 11 | //cout << i << j; 12 | cin >> matrix[i][j]; 13 | } 14 | //cout << endl; 15 | } 16 | //cout << endl; 17 | int i_pos, j_pos; 18 | for(i=0; i<5; i++){ 19 | for(j=0; j<5; j++){ 20 | if(matrix[i][j]==1){ 21 | i_pos = i+1; 22 | j_pos = j+1; 23 | break; 24 | } 25 | //cout << matrix[i][j]; 26 | } 27 | //cout << endl; 28 | } 29 | int total_move = abs(i_pos - 3) + abs(j_pos - 3); 30 | cout << total_move << endl; 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /codeforces - 282A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin >> n; 8 | string state; 9 | int x=0; 10 | for(int i=0; i> state; 12 | if(state[1]=='+') x++; 13 | else if(state[1]='--') x--; 14 | } 15 | cout << x << endl; 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /codeforces - 339A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | string sum; 7 | cin >> sum; 8 | int len = sum.length(); 9 | //cout << len; 10 | //cout << sum << endl; 11 | int temp; 12 | for(int i=0; isum[j+2]){ 15 | //swap(sum[i], sum[i+2]); 16 | temp=sum[j+2]; 17 | sum[j+2]=sum[j]; 18 | sum[j]=temp; 19 | } 20 | } 21 | //cout << sum[i] << endl; 22 | } 23 | cout << sum << endl; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /codeforces - 379A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int a, b; 7 | cin >> a >> b; 8 | int sum = a; 9 | while(a>=b){ 10 | sum = sum + (a/b); 11 | a = ((a/b) + (a%b)); 12 | } 13 | cout << sum << endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /codeforces - 451A.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int n, m; 5 | int grid, counter; 6 | while(scanf("%d %d", &n, &m)!=EOF){ 7 | grid = n*m; 8 | counter = 0; 9 | while(grid!=0){ 10 | n=n-1; 11 | m=m-1; 12 | grid=n*m; 13 | counter++; 14 | } 15 | if(counter%2==1) printf("Akshat\n"); 16 | else if(counter%2==0) printf("Malvika\n"); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /codeforces - 467B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool bitChecker(int n, int pos){ 6 | return n & (1 << pos); 7 | } 8 | 9 | int main(){ 10 | int n, m, k; 11 | int fedor; 12 | //cin >> n >> m >> k; 13 | scanf("%d %d %d", &n, &m, &k); 14 | int player[m]; 15 | for(int i=0; i 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int m, n; 7 | cin >> m >> n; 8 | cout << (m*n)/2 << endl; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /codeforces - 546A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int k, n, w; 7 | cin >> k >> n >> w; 8 | int needMoney = 0; 9 | for(int i=1; i<=w; i++){ 10 | needMoney+=(i*k); 11 | } 12 | if(needMoney>n) cout << needMoney-n << endl; 13 | else cout << "0" << endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /codeforces - 622B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int hh, mm; 7 | int a; 8 | while(scanf("%d:%d", &hh, &mm)!=EOF){ 9 | scanf("%d", &a); 10 | mm = mm + a; 11 | if(mm>=60){ 12 | hh = hh + (mm/60); 13 | mm = mm%60; 14 | } 15 | if(hh>=24){ 16 | hh = hh%24; 17 | } 18 | printf("%02d:%02d\n", hh, mm); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /codeforces - 69A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | int x, y, z; 8 | int sum_x = 0, sum_y = 0, sum_z = 0; 9 | cin >> n; 10 | for(int i=0; i> x >> y >> z; 12 | sum_x = sum_x + x; 13 | sum_y = sum_y + y; 14 | sum_z = sum_z + z; 15 | } 16 | if(sum_x==0 && sum_y==0 && sum_z==0) cout << "YES" << endl; 17 | else cout << "NO" << endl; 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /codeforces - 714A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(){ 7 | long long l1, r1, l2, r2, k; 8 | cin >> l1 >> r1 >> l2 >> r2 >> k; 9 | long long time = 0; 10 | long long int start_count, end_count; 11 | if(l2>=l1) start_count = l2; 12 | else start_count = l1; 13 | if(r2>=r1) end_count = r1; 14 | else end_count = r2; 15 | /* 16 | for(i=start_count; i<=end_count; i++){ 17 | time++; 18 | if(i==k) time--; 19 | } 20 | */ 21 | if(end_count >= start_count){ 22 | time = (end_count - start_count)+1; 23 | if(k>=start_count && k<=end_count) 24 | time=time-1; 25 | } 26 | //cout << time << endl; 27 | cout << time << endl; 28 | //printf("%I64d\n", time); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /codeforces - 71A.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | int n, i, len; 6 | char word[101]; 7 | scanf("%d", &n); 8 | for(i=0; i10){ 14 | printf("%c%d%c\n", word[0], len-2, word[len-1]); 15 | } 16 | else printf("%s\n", word); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /codeforces - 71A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | string word; 8 | cin >> n; 9 | for(int i=0; i> word; 11 | if(word.length()>10){ 12 | cout << word[0] << word.length()-2 << word[word.length()-1] << endl; 13 | } 14 | else 15 | cout << word << endl; 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /codemarshal - Celebrating Victory.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("Yaayy!! Bangladesh Won!!\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /codemarshal - area of triangle.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | int test, a, b, c, i; 6 | double s, area; 7 | scanf("%d", &test); 8 | for(i=1; i<=test; i++) 9 | { 10 | scanf("%d %d %d", &a, &b, &c); 11 | s = (a+b+c)/(double)2; 12 | area = sqrt(s*(s-a)*(s-b)*(s-c)); 13 | printf("Case %d: %.10lf\n", i, area); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /codemarshal - average mark.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | main() 4 | { 5 | int i, j, test, student, mark, sum, avg; 6 | scanf("%d", &test); 7 | for(i=1; i<=test; i++) 8 | { 9 | sum = 0; 10 | scanf("%d", &student); 11 | for(j=1; j<=student; j++) 12 | { 13 | 14 | scanf("%d", &mark); 15 | sum = sum + mark; 16 | } 17 | avg = sum/ student; 18 | printf("Case %d: %d\n", i, avg); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codemarshal - grading method.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int st_num, mark, i; 5 | scanf("%d", &st_num); 6 | for(i=1; i<=st_num; i++) 7 | { 8 | scanf("%d", &mark); 9 | if(90<=mark) printf("Student %d: A+\n", i); 10 | else if(80<=mark) printf("Student %d: A\n", i); 11 | else if(70<=mark) printf("Student %d: A-\n", i); 12 | else if(60<=mark) printf("Student %d: B+\n", i); 13 | else if(50<=mark) printf("Student %d: B-\n", i); 14 | else if(40<=mark) printf("Student %d: C\n", i); 15 | else if(35<=mark) printf("Student %d: D\n", i); 16 | else if(0<=mark) printf("Student %d: F\n", i); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /codemarshal - maximum number.c: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | int a, b, c, test, i; 5 | scanf("%d", &test); 6 | for(i=1; i<=test; i++) 7 | { 8 | scanf("%d %d %d", &a, &b, &c); 9 | if(a>b && a>c) 10 | printf("Case %d: %d\n", i, a); 11 | else if(b>c && b>a) 12 | printf("Case %d: %d\n", i, b); 13 | else if(c>a && c>b) 14 | printf("Case %d: %d\n", i, c); 15 | else if(a==b && b==c && c==a) 16 | printf("Case %d: %d\n", i, a); 17 | else if(a==b && a>c) 18 | printf("Case %d: %d\n", i, a); 19 | else if(a>b && a==c) 20 | printf("Case %d: %d\n", i, a); 21 | else if(b==a && b>c) 22 | printf("Case %d: %d\n", i, b); 23 | else if(b>a && b==c) 24 | printf("Case %d: %d\n", i, b); 25 | else if(c==a && c>b) 26 | printf("Case %d: %d\n", i, c); 27 | else if(c>a && c==b) 28 | printf("Case %d: %d\n", i, c); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /codemarshal - multiplication table.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int test, i, j, number; 6 | 7 | scanf("%d", &test); 8 | for(i=1; i<=test; i++) 9 | { 10 | printf("Case %d:\n", i); 11 | scanf("%d", &number); 12 | for(j=1; j<=10; j++) 13 | { 14 | printf("%d * %d = %d\n", number, j, number*j); 15 | } 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /codemarshal - pyramid of number - shoib.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,j,n,k,test; 5 | scanf("%d",&test); 6 | for(k=1;k<=test;k++) 7 | { 8 | scanf("%d",&n); 9 | printf("Case %d:\n",k); 10 | for(i=1;i<=n;i++) 11 | { 12 | for(j=1;j<=i;j++) 13 | { 14 | printf("%d",j); 15 | } 16 | printf("\n"); 17 | } 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /codemarshal - pyramid of number.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i, j, k, test, num; 5 | scanf("%d",&test); 6 | for(i=1; i<=test; i++) 7 | { 8 | scanf("%d",&num); 9 | printf("Case %d:\n",i); 10 | for(j=1; j<=num; j++) 11 | { 12 | for(k=1; k<=j; k++) 13 | { 14 | printf("%d",k); 15 | } 16 | printf("\n"); 17 | } 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /codemarshal - pyramid of stars.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int test, star, i, j, k, l, m; 5 | scanf("%d", &test); 6 | for(i=1; i<=test; i++) 7 | { 8 | scanf("%d", &star); 9 | printf("Case %d:\n", i); 10 | for(j=1; j<=star; j++) 11 | { 12 | for(k=1; k<=j; k++) 13 | { 14 | printf("*"); 15 | } 16 | printf("\n"); 17 | } 18 | for(l=star-1; l>=1; l--) 19 | { 20 | for(m=l; m>=1; m--) 21 | { 22 | printf("*"); 23 | } 24 | printf("\n"); 25 | } 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /codemarshal - series of number.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | int n[1000] , dr, i, j, test, num, value; 6 | scanf("%d", &test); 7 | for(i=0; i 2 | #include 3 | 4 | int main() 5 | { 6 | int test,m,i,j,k[1000],sum, dr; 7 | scanf("%d",&test); 8 | for(i=1;i<=test;i++) 9 | { 10 | scanf("%d",&m); 11 | for(j=0;j