April Fools Contest 2017, problem: (G) BF Calculator Solution in C/C++

By |2017-04-10T00:39:21+00:00April 10th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<cstdio> int main() { int ans=0,a=0; char c; scanf("%d",&ans); while (scanf("%c%d",&c,&a) != EOF) { if (c=='+') ans+=a; if (c=='-') ans-=a; } a=0; if (ans==0) { printf("++++++++++++++++++++++++++++++++++++++++++++++++."); return 0; } while (ans) { int x=ans%10; for (int i=1;i<=x;i++) printf("+"); printf("++++++++++++++++++++++++++++++++++++++++++++++++"); printf(">"); ans/=10; a++; } while [...]

April Fools Contest 2017, problem: (F) Crunching Numbers Just for You Solution in C

By |2017-04-10T00:32:49+00:00April 10th, 2017|Categories: C/C++, Programming|Tags: , , |

#include <stdio.h> #include<algorithm> #include<time.h> using namespace std; int a[100]; int main() { int n,i; clock_t t0; t0=clock(); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",a+i); } for(;(clock()-t0)/CLOCKS_PER_SEC<=1.0;); sort(a,a+n); for(i=0;i<n;i++) printf("%d ",a[i]); return 0; }

April Fools Contest 2017, problem: (D) Touchy-Feely Palindromes Solution in C

By |2017-04-09T23:54:03+00:00April 9th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include <stdio.h> #include <string.h> int main(){ int i, num, flag=0; char str[11]; scanf("%s", str); num = strlen(str); if(num == 1){ if(str[0] == '3' || str[0] == '7'){ printf("Yes\n"); } else printf("No\n"); } else{ for(i=0; i<num/2; i++){ if(str[i] == '1' || str[i] == '2'){ printf("No\n"); [...]

April Fools Contest 2017, problem: (C) INTERCALC Solution in C

By |2017-04-09T23:49:28+00:00April 9th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<stdio.h> int main(){ int a[10], i, n, max=0; scanf("%d", &n); for(i=0; i<n; i++){ scanf("%d", &a[i]); if(max<a[i]) max=a[i]; } printf("%d", max^a[n-1]); return 0; }

April Fools Contest 2017, problem: (B) Kids’ Riddle Solution in C

By |2017-04-09T23:45:21+00:00April 9th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<stdio.h> int main(void) { unsigned x, y, result = 0; scanf("%u", &x); do { y = x & 15; x >>= 4; if (y == 0 || y == 4 || y == 6 || y == 9 || y == 10 || y [...]

April Fools Contest 2017, problem: (A) Numbers Joke Solution in C

By |2017-04-09T23:41:14+00:00April 9th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<stdio.h> int main(void) { int mas[30] = {4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645}; int i; scanf("%d", &i); printf("%d", mas[i - [...]