Posts

Showing posts from November, 2018

Codeforces solution 112A Petya and Strings

Image
#include <stdio.h> int main () { int n ; char a [ 200 ], b [ 200 ]; gets ( a ); gets ( b ); n = strcmpi ( a , b ); printf ( "%d\n" , n ); return 0 ; }

Codeforces Solution 230B T-primes

Image
#include < bits / stdc ++. h > using namespace std ; int arr [ 10000000 ]; int main () { int i , j ; arr [ 0 ]= arr [ 1 ]= 1 ; for ( i = 2 ; i * i <= 10000000 ; i ++) { if ( arr [ i ]== 0 ) { for ( j = 2 ; i * j <= 10000000 ; j ++) { arr [ i * j ]= 1 ; } } } int n , t ; cin >> n ; long long int in ; for ( int i = 0 ; i < n ; i ++) { cin >> in ; t = sqrt ( in ); if ( t == sqrt ( in )&& arr [ t ]== 0 ) { cout << "YES" << endl ; } else cout << "NO" << endl ; } return 0 ; }

Uri Solution 1387 Og

Image
#include<stdio.h> int main() {     int a,b;     while(1)     {       scanf("%d %d",&a,&b);       if(a==0 && b==0)       {           break;       }       printf("%d\n",a+b);     }     return 0; }