├── README.md ├── 2617.sql ├── 2058.cpp ├── 2679.cpp ├── 2839.cpp ├── 1959.cpp ├── 1004.cpp ├── 1007.cpp ├── 1011.cpp ├── 1014.cpp ├── 2234.cpp ├── 1003.cpp ├── 1795.cpp ├── 2146.cpp ├── 1013.cpp ├── 1379.cpp ├── 1930.cpp ├── 2653.cpp ├── 1002.cpp ├── 1143.cpp ├── 1708.cpp ├── 1017.cpp ├── 1197.cpp ├── 1323.cpp ├── 1589.cpp ├── 2159.cpp ├── 1095.cpp ├── 1963.cpp ├── 2006.cpp ├── 2497.cpp ├── 1009.cpp ├── 1026.cpp ├── 1059.cpp ├── 1067.cpp ├── 1078.cpp ├── 1097.cpp ├── 2483.cpp ├── 2896.cpp ├── 1098.cpp ├── 1008.cpp ├── 1155.cpp ├── 1300.cpp ├── 1044.cpp ├── 1073.cpp ├── 1149.cpp ├── 1153.cpp ├── 1805.cpp ├── 1924.cpp ├── 2867.cpp ├── 1156.cpp ├── 1864.cpp ├── 2334.cpp ├── 1387.cpp ├── 2840.cpp ├── 1564.cpp ├── 1585.cpp ├── 1760.cpp ├── 1921.cpp ├── 1001.java ├── 1010.cpp ├── 1015.cpp ├── 1075.cpp ├── 1177.cpp ├── 1428.cpp ├── 2454.cpp ├── 1759.cpp ├── 2172.cpp ├── 1145.cpp ├── 2160.cpp ├── 2598.cpp ├── 1060.cpp ├── 2165.cpp ├── 2670.cpp ├── 2682.cpp ├── 2987.cpp ├── 1144.cpp ├── 1865.cpp ├── 2516.cpp ├── 1016.cpp ├── 1512.cpp ├── 1043.cpp ├── 1065.cpp ├── 1079.cpp ├── 1113.cpp ├── 1308.cpp ├── 1150.cpp ├── 1866.cpp ├── 1046.cpp ├── 1172.cpp ├── 2003.cpp ├── 2061.cpp ├── 1401.cpp ├── 1612.cpp ├── 2217.cpp ├── 1070.cpp ├── 1169.cpp ├── 1170.cpp ├── 2147.cpp ├── 2175.cpp ├── 2495.cpp ├── 2547.cpp ├── 1173.cpp ├── 1436.cpp ├── 1962.cpp ├── 1072.cpp ├── 1154.cpp ├── 1467.cpp ├── 2176.cpp ├── 2651.cpp ├── 1117.cpp ├── 1893.cpp ├── 1929.cpp ├── 1036.cpp ├── 1114.cpp ├── 1984.cpp ├── 2544.cpp ├── 1175.cpp ├── 1178.cpp ├── 1393.cpp ├── 1038.cpp ├── 1064.cpp ├── 1132.cpp ├── 1096.cpp ├── 2057.cpp ├── 2235.cpp ├── 2534.cpp ├── 2029.cpp ├── 1012.cpp ├── 1142.cpp ├── 1235.cpp ├── 1133.cpp ├── 2702.cpp ├── 1157.cpp ├── 1397.cpp ├── 1858.cpp ├── 2510.cpp ├── 2523.cpp ├── 1080.cpp ├── 1151.cpp ├── 2514.cpp ├── 1183.cpp ├── 1184.cpp ├── 1019.cpp ├── 1020.cpp ├── 1414.cpp ├── 1987.cpp ├── 2170.cpp ├── 1115.cpp ├── 1743.cpp ├── 1134.cpp ├── 1796.cpp ├── 2581.java ├── 1116.cpp ├── 1182.cpp ├── 1198.cpp ├── 1943.cpp ├── 2167.cpp ├── 1164.cpp ├── 1609.cpp ├── 1546.cpp ├── 2242.cpp ├── 2540.cpp ├── 1329.cpp ├── 2150.cpp ├── 1146.cpp ├── 1174.cpp ├── 1332.cpp ├── 2592.cpp ├── 2152.cpp ├── 1047.cpp ├── 1158.cpp ├── 1188.cpp ├── 1159.cpp ├── 1180.cpp ├── 2591.cpp ├── 2815.cpp ├── 1087.cpp ├── 1165.cpp ├── 1181.cpp ├── 1221.cpp ├── 2166.cpp ├── 2149.cpp ├── 2161.cpp ├── 1035.cpp ├── 2129.cpp ├── 2174.cpp ├── 2232.cpp ├── 2311.cpp ├── 2060.cpp ├── 1069.cpp ├── 1581.cpp ├── 1953.cpp ├── 2543.java ├── 2863.cpp ├── 1259.cpp ├── 1296.cpp ├── 2484.cpp ├── 2496.cpp ├── 1029.cpp ├── 1176.cpp ├── 1542.java ├── 1037.cpp ├── 2753.cpp ├── 2762.cpp ├── 2663.cpp ├── 1548.cpp ├── 1041.cpp ├── 1071.cpp ├── 1136.cpp ├── 1961.cpp ├── 1238.cpp ├── 2533.java ├── 1789.cpp ├── 1257.cpp ├── 1192.cpp ├── 1429.cpp ├── 2766.cpp ├── 1240.cpp ├── 1241.cpp ├── 1214.cpp ├── 1410.cpp ├── 1555.cpp ├── 2180.cpp ├── 2692.cpp ├── 2116.cpp ├── 1582.cpp ├── 1050.cpp ├── 1042.cpp ├── 1161.cpp ├── 1534.cpp ├── 1914.cpp ├── 1099.cpp ├── 1933.cpp ├── 1985.cpp ├── 2551.cpp ├── 2780.cpp ├── 1049.cpp ├── 1252.cpp ├── 2765.cpp ├── 2791.cpp ├── 2759.cpp ├── 1310.cpp ├── 1536.cpp ├── 2763.cpp ├── 1215.cpp ├── 1213.cpp ├── 1028.cpp ├── 1847.cpp ├── 1091.cpp ├── 2091.cpp ├── 2717.cpp ├── 1957.cpp ├── 2786.cpp ├── 1066.cpp ├── 1869.cpp ├── 2722.cpp ├── 1768.cpp ├── 1045.cpp ├── 1249.cpp ├── 2062.cpp ├── 2633.cpp ├── 2850.cpp ├── 2044.cpp ├── 1052.cpp ├── 1219.cpp ├── 1256.cpp ├── 2356.cpp ├── 1273.cpp ├── 2787.cpp ├── 2866.cpp ├── 2579.cpp ├── 2674.cpp ├── 2756.cpp ├── 1237.cpp ├── 1118.cpp ├── 1260.cpp ├── 2059.cpp ├── 2600.cpp ├── 1239.cpp ├── 1437.cpp ├── 1160.cpp ├── 1129.cpp ├── 1068.cpp ├── 2310.cpp ├── 2582 .cpp ├── 1051.cpp ├── 2568.cpp ├── 1120.cpp ├── 2455.cpp ├── 1267.cpp ├── 1024.cpp ├── 1871.cpp ├── 1944.cpp ├── 1179.cpp ├── 1371.cpp ├── 1520.cpp ├── 1848.cpp ├── 2596.cpp ├── 1101.cpp ├── 1262.cpp ├── 2144.cpp ├── 2752.cpp ├── 1162.cpp ├── 2748.cpp ├── 2749.cpp ├── 2826.java ├── 2936.cpp ├── 1131.cpp ├── 2251.cpp ├── 2508.cpp ├── 2747.cpp ├── 1547.cpp ├── 1516.cpp ├── 1306.cpp ├── 1577.cpp ├── 2440.cpp ├── 1168.cpp ├── 2926.cpp ├── 2548.cpp ├── 2542.cpp ├── 2694.cpp ├── 2154.cpp ├── 2567.cpp ├── 1800.cpp ├── 2764.cpp ├── 2253.cpp ├── 2708.cpp ├── 2163.cpp ├── 2630.cpp └── 2084.cpp /README.md: -------------------------------------------------------------------------------- 1 | # uri online judge solutions 2 | -------------------------------------------------------------------------------- /2617.sql: -------------------------------------------------------------------------------- 1 | select products.name,providers.name from products inner 2 | join providers on providers.id=products.id_providers 3 | where providers.name='Ajax SA'; 4 | -------------------------------------------------------------------------------- /2058.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | long long x; 8 | cin>>x; 9 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a; 6 | cin>>a; 7 | if(a%2==0)cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | long long n; 8 | while(cin>>n) 9 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | long long x,y; 7 | cin>>x>>y; 8 | x=x*y;cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a,b; 8 | cin>>a>>b; 9 | a=a*b; 10 | cout<<"PROD = "< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c,d; 6 | cin>>a>>b>>c>>d; 7 | int x; 8 | x=(a*b)-(c*d); 9 | cout<<"DIFERENCA = "< 2 | using namespace std; 3 | int main() 4 | { 5 | double r; 6 | cin>>r; 7 | r=(4/3.0)*r*r*r*3.14159; 8 | printf("VOLUME = %.3lf\n",r); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /1014.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int X; 6 | double Y; 7 | cin>>X>>Y; 8 | Y=X/Y; 9 | printf("%.3lf km/l\n",Y); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /2234.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | double x,y; 7 | cin>>x>>y; 8 | y=x/y; 9 | printf("%.2lf\n",y); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /1003.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a,b; 8 | cin>>a>>b; 9 | a=a+b; 10 | cout<<"SOMA = "< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | long long tri; 8 | tri=pow(3,n); 9 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int n; 8 | while(cin>>n) 9 | { 10 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a[3]; 6 | cin>>a[0]>>a[1]>>a[2]; 7 | sort(a,a+3); 8 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | long long a, b; 6 | while (cin >> a >> b && (a + b)) { 7 | cout << a - (b - a) << endl; 8 | } 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /1930.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a,b,c,d; 8 | cin>>a>>b>>c>>d; 9 | a=a+b+c+d-3; 10 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | set x; 6 | string y; 7 | while(cin>>y) 8 | x.insert(y); 9 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | double x; 8 | cin>>x; 9 | x=x*x*3.14159; 10 | printf("A=%.4lf\n",x); 11 | 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /1143.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | for(int i=1;i<=t;i++) 10 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | double a,b; 6 | double c; 7 | cin>>a>>b; 8 | a=abs(a-b); 9 | c=ceil(b/a); 10 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int hour,speed; 6 | double liter; 7 | cin>>hour>>speed; 8 | hour=hour*speed; 9 | liter=hour/12.0; 10 | printf("%.3lf\n",liter); 11 | } 12 | -------------------------------------------------------------------------------- /1197.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a,b; 8 | while((scanf("%d%d",&a,&b))!=EOF) 9 | { 10 | cout<<2*a*b< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | while(cin>>n&&n) 7 | { 8 | long long x=(n*(n+1)*(2*n+1))/6; 9 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,t; 6 | cin>>t; 7 | while(t>0) 8 | { 9 | cin>>a>>b; 10 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | long long n; 6 | cin>>n; 7 | double x,y; 8 | x=n/log(n); 9 | y=x*1.25506; 10 | printf("%.1lf %.1lf\n",x,y); 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /1095.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | for(int i=1,j=60;;i+=3,j-=5) 8 | { 9 | cout<<"I="< 2 | using namespace std; 3 | int main() 4 | { 5 | int x,y,r=0; 6 | cin>>x; 7 | for(int i=1;i<=5;i++) 8 | { 9 | cin>>y; 10 | if(y==x) 11 | r++; 12 | } 13 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | int i=0; 7 | while(cin>>n&&n>=0) 8 | { 9 | printf("Experiment %d: %d full cycle(s)\n",++i,n/2); 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /1009.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | string a; 8 | float x,y; 9 | cin>>a>>x>>y; 10 | y=y*15/100; 11 | x=x+y; 12 | printf("TOTAL = R$ %.2f\n",x); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /1026.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | long long x,y; 6 | while(cin>>x>>y) 7 | { 8 | long long z; 9 | z=x^y; 10 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | for(int i=2;i<=100;i++) 7 | { 8 | if(i%2==0) 9 | { 10 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int X; 8 | cin>>X; 9 | for(int i=1;i<=X;i++) 10 | { 11 | if(i%2!=0) 12 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int N; 8 | cin>>N; 9 | for(int i=1;i<=10;i++) 10 | { 11 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t,n,k; 8 | cin>>t; 9 | while(t--) 10 | { 11 | cin>>n>>k; 12 | cout<<(n%k)+(n/k)< 2 | using namespace std; 3 | int main() 4 | { 5 | for(double i=0;i<=2;i+=.2) 6 | { 7 | for(double j=1;j<=3;j++) 8 | { 9 | cout<<"I="< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | double sum=0.0; 8 | for(int i=1;i<=100;i++) 9 | { 10 | sum=sum+(1.0/i); 11 | } 12 | printf("%.2lf\n",sum); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /1300.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | 8 | while(cin >> n) 9 | { 10 | if(n % 6 == 0){ 11 | cout << "Y" << '\n'; 12 | }else{ 13 | cout << "N" << '\n'; 14 | } 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /1044.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b; 6 | cin>>a>>b; 7 | a=abs(a); 8 | b=abs(b); 9 | if(b>a)swap(a,b); 10 | if(a%b==0)cout<<"Sao Multiplos\n"; 11 | else cout<<"Nao sao Multiplos\n"; 12 | } 13 | -------------------------------------------------------------------------------- /1073.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int N; 8 | cin>>N; 9 | for(int i=1;i<=N;i++) 10 | { 11 | if(i%2==0) 12 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,sum=0; 6 | cin>>a>>b; 7 | while(b<=0) 8 | cin>>b; 9 | for(int i=1;i<=b;i++) 10 | { 11 | sum=sum+a; 12 | a++; 13 | } 14 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n; 7 | int sum=1; 8 | cin>>n; 9 | for(int i=2;i<=n;i++) 10 | { 11 | sum=sum*i; 12 | } 13 | cout< 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main (){ 7 | 8 | long long int soma = 0; 9 | long long int a,b; 10 | 11 | cin >> a >> b; 12 | 13 | soma = (a + b) * (b-a+1)/2; 14 | 15 | cout << soma << endl; 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /1924.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | while(t-->0) 10 | { 11 | string g; 12 | cin>>g; 13 | } 14 | cout<<"Ciencia da Computacao\n"; 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /2867.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | int n,m; 8 | while(t--) 9 | { 10 | cin>>n>>m; 11 | double lg=log10(n); 12 | lg*=m; 13 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | double sum=0.0,i,j; 8 | for(j=1,i=1;j<=39;j=j+2,i=i*2) 9 | { 10 | sum=sum+(j/i); 11 | } 12 | printf("%.2lf\n",sum); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /1864.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | string s="LIFE IS NOT A PROBLEM TO BE SOLVED"; 8 | int a; 9 | cin>>a; 10 | for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | unsigned long long n; 6 | while(cin>>n) 7 | { 8 | if(n == -1) break; 9 | if(n == 0) printf("0\n"); 10 | else printf("%llu\n", n - 1); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /1387.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int n,m; 8 | cin>>n>>m; 9 | while(n!=0&&m!=0) 10 | { 11 | int a=0; 12 | a=n+m; 13 | cout<>n>>m; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /2840.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | typedef long long ll; 6 | #define INF 99999999 7 | int main() 8 | { 9 | double a,b; 10 | cin>>a>>b; 11 | double r=pow(a,3); 12 | a= 1.333333333 * (3.1415*r); 13 | int g=b/a; 14 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int x; 7 | while((scanf("%d",&x))!=EOF) 8 | { 9 | if(x>0) 10 | cout<<"vai ter duas!\n"; 11 | else 12 | cout<<"vai ter copa!\n"; 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /1585.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | 5 | int main() 6 | { 7 | int cases; scanf("%d", &cases); 8 | 9 | 10 | while(cases--) 11 | { 12 | int x, y; scanf("%d %d", &x, &y); 13 | 14 | 15 | printf("%d cm2\n", (x*y)/2); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /1760.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | //freopen("uva.txt","w",stdout); 6 | double a; 7 | while(cin>>a) 8 | { 9 | double r=sqrt(3)/4.00; 10 | double area=r*a*a; 11 | printf("%.2f\n",area*1.6); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /1921.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | int se=0; 8 | long long sum=0; 9 | for(int i=4;i<=n;i++) 10 | { 11 | if(i==4)se=2; 12 | else se++; 13 | sum+=se; 14 | } 15 | cout< 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | float x1,x2,y1,y2; 9 | cin>>x1>>y1; 10 | cin>>x2>>y2; 11 | x1=(x2-x1)*(x2-x1); 12 | y1=(y2-y1)*(y2-y1); 13 | x1=sqrt(x1+y1); 14 | printf("%.4lf\n",x1); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /1075.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int n; 8 | cin>>n; 9 | cout<<"2\n"; 10 | for(int i=n;i<=10000;i++) 11 | { 12 | if(i%n==0) 13 | { 14 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a[1000]; 6 | int t; 7 | cin>>t; 8 | for(int i=0,j=0;i<1000;i++,j++) 9 | { 10 | if(j>=t) 11 | j=0; 12 | a[i]=j; 13 | printf("N[%d] = %d\n",i,a[i]); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /1428.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | double a,b; 8 | while(t--) 9 | { 10 | cin>>a>>b; 11 | int A=ceil((a-2)/3); 12 | int B=ceil((b-2)/3); 13 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b; 6 | cin>>a>>b; 7 | if(a==0) 8 | cout<<"C\n"; 9 | else 10 | { 11 | if(b==0) 12 | cout<<"B\n"; 13 | else 14 | cout<<"A\n"; 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /1759.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int t; 7 | cin>>t; 8 | for(int i=1;i<=t;i++) 9 | { 10 | cout<<"Ho"; 11 | if(i==t) 12 | cout<<"!\n"; 13 | else 14 | cout<<" "; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /2172.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int a; 7 | long long x; 8 | long long y; 9 | cin>>a>>x; 10 | while(a!=0&&x!=0) 11 | { 12 | y=x*a; 13 | cout<>a>>x; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /1145.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int x,y; 7 | cin>>x>>y; 8 | for(int i=1;i<=y;i++) 9 | { 10 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | char a[502]; 9 | gets(a); 10 | int len=strlen(a); 11 | if(len<=80) 12 | cout<<"YES\n"; 13 | else 14 | 15 | cout<<"NO\n"; 16 | 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /2598.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | //freopen("c.txt","w",stdout); 5 | int a; 6 | cin>>a; 7 | while(a--){ 8 | int m,n; 9 | cin>>m>>n; 10 | if(m 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | double num[6],positive=0; 8 | for(int i=0;i<6;i++) 9 | { 10 | cin>>num[i]; 11 | if(num[i]>0) 12 | positive++; 13 | } 14 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | char a[502]; 9 | gets(a); 10 | int len=strlen(a); 11 | if(len<=140) 12 | cout<<"TWEET\n"; 13 | else 14 | 15 | cout<<"MUTE\n"; 16 | 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /2670.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c; 6 | cin>>a>>b>>c; 7 | vector time(3); 8 | time[0]=(b*2)+(c*4); 9 | time[1]=(a*2)+(c*2); 10 | time[2]=(b*2)+(a*4); 11 | sort(time.begin(),time.end()); 12 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | int max=0; 7 | bool wrong=false; 8 | while(cin>>n) 9 | { 10 | if(n>max&&!wrong)max=n; 11 | else 12 | { 13 | wrong=true; 14 | } 15 | } 16 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | /** 8 | * Escreva a sua solução aqui 9 | * Code your solution here 10 | * Escriba su solución aquí 11 | */ 12 | char c; 13 | 14 | cin>>c; 15 | cout< 2 | int main() 3 | { 4 | int a,b,c,d,e,f; 5 | scanf("%d", &a); 6 | for(b=1; b<=a; b++) 7 | { 8 | c=b*b; 9 | d=b*b*b; 10 | printf("%d %d %d\n",b,c,d); 11 | e=c+1; 12 | f=d+1; 13 | printf("%d %d %d\n",b,e,f); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /1865.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | string x; 8 | int n,t; 9 | cin>>t; 10 | while(t-->0) 11 | { 12 | cin>>x>>n; 13 | if(x=="Thor") 14 | cout<<"Y\n"; 15 | else 16 | cout<<"N\n"; 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /2516.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | double s,va,vb; 6 | while(cin>>s>>va>>vb) 7 | { 8 | if(va<=vb)cout<<"impossivel\n"; 9 | else 10 | { 11 | double time=s/(va-vb)*1.00; 12 | printf("%.2lf\n",time); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /1016.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | /** 8 | * Escreva a sua solução aqui 9 | * Code your solution here 10 | * Escriba su solución aquí 11 | */ 12 | int a; 13 | cin>>a; 14 | a=a*2; 15 | cout< 2 | using namespace std; 3 | int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } 4 | int main(){ 5 | int n,a,b; 6 | while(cin>>n&&n){ 7 | cin >> a; 8 | cin >> b; 9 | int lcm=(a*b)/gcd(a,b); 10 | int x = (n/a) + (n/b) - (n/lcm); 11 | printf("%d\n",x); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /1043.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | float a,b,c; 6 | cin>>a>>b>>c; 7 | if((a+b>c)&&(a+c>b)&&(c+b>a)) 8 | { 9 | printf("Perimetro = %.1f\n",a+b+c); 10 | } 11 | else{ 12 | a=((a+b)*c)/2; 13 | printf("Area = %.1f\n",a); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /1065.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int a[5],count=0; 7 | for(int i=0;i<5;i++) 8 | { 9 | cin>>a[i]; 10 | if(a[i]%2==0) 11 | { 12 | count++; 13 | } 14 | } 15 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | double a,b,c,d; 9 | cin>>t; 10 | while(t>0) 11 | { 12 | cin>>a>>b>>c; 13 | d=(a*2)+(b*3)+(c*5); 14 | d=d/10; 15 | printf("%.1lf\n",d); 16 | t--; 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /1113.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int X,Y; 8 | for(;;) 9 | { 10 | cin>>X>>Y; 11 | if(X>Y) 12 | cout<<"Decrescente\n"; 13 | if(X 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | //freopen("uri.txt","w",stdout); 7 | int t; 8 | scanf("%d",&t); 9 | while(t--) 10 | { 11 | ll x; 12 | cin>>x; 13 | x=(sqrt(1+8*x)-1)/2; 14 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int x,z; 7 | cin>>x>>z; 8 | while(z<=x) 9 | cin>>z; 10 | int i,j,sum=0; 11 | for(i=x,j=1;;j++,i++) 12 | { 13 | sum=sum+i; 14 | if(sum>z) 15 | break; 16 | } 17 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | int x; 10 | while(t>0) 11 | { 12 | cin>>x; 13 | if(x%2==0) 14 | cout<<0< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c; 6 | cin>>a>>b; 7 | if(a>b) 8 | { 9 | c=24-a+b; 10 | } 11 | if(a 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int x[10]; 7 | for(int i=0;i<10;i++) 8 | { 9 | cin>>x[i]; 10 | } 11 | for(int i=0;i<10;i++) 12 | { 13 | if(x[i]<=0) 14 | x[i]=1; 15 | printf("X[%d] = %d\n",i,x[i]); 16 | } 17 | 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /2003.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b; 6 | char c; 7 | while(cin>>a>>c>>b) 8 | { 9 | int A=a-7; 10 | int B=b; 11 | if(A<0)cout<<"Atraso maximo: 0\n"; 12 | else{ 13 | printf("Atraso maximo: %d\n",(A*60)+b); 14 | } 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /2061.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | string str; 8 | int m,n; 9 | cin>>m>>n; 10 | for(int i=1;i<=n;i++) 11 | { 12 | cin>>str; 13 | if(str=="fechou") 14 | m++; 15 | else 16 | m--; 17 | } 18 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | string s; 7 | cin >> n; 8 | for (int i = 0; i < n; i++) { 9 | cin >> s; 10 | sort(s.begin(), s.end()); 11 | do { 12 | cout << s << endl; 13 | } while (next_permutation(s.begin(), s.end())); 14 | cout << endl; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /1612.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | 6 | int main() 7 | { 8 | int n, r; 9 | double x; 10 | 11 | 12 | scanf("%i", &n); 13 | 14 | 15 | for (int i = 0; i < n; ++i) 16 | { 17 | scanf("%lf", &x); 18 | r = ceil(x/2); 19 | printf("%i\n", r); 20 | } 21 | 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /2217.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | int n; 10 | cin>>n; 11 | if(n%2==0) 12 | { 13 | cout<<"1\n"; 14 | } 15 | else 16 | { 17 | cout<<"9\n"; 18 | } 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /1070.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | unsigned int X; 8 | int counter=0; 9 | cin>>X; 10 | for(int i=X;;i++) 11 | { 12 | if(i%2!=0) 13 | { 14 | cout< 2 | #include > 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | int t,n,b=1; 9 | unsigned long long sum=0; 10 | cin>>t; 11 | while(t>0) 12 | { 13 | cin>>n; 14 | sum=pow(2,n)/12000; 15 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | while(t-->0) 10 | { 11 | int d=0; 12 | float x; 13 | cin>>x; 14 | while(x>1.0){ 15 | d++; 16 | x=x/2.00; 17 | } 18 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | int n; 9 | cin>>n; 10 | while(n--) 11 | { 12 | char x[10001]; 13 | cin>>x; 14 | int c=strlen(x); 15 | double z=.01*c; 16 | printf("%.2lf\n",z); 17 | 18 | 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /2175.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | float x,y,z; 6 | cin>>x>>y>>z; 7 | if(x==y||y==z||x==z) 8 | cout<<"Empate"< 2 | using namespace std; 3 | int main(){ 4 | int t; 5 | while(cin>>t){ 6 | int a[t]; 7 | for(int i=0;i>a[i]; 9 | sort(a,a+t-1); 10 | bool c=false; 11 | for(int i=0;i 2 | using namespace std; 3 | int main(){ 4 | int t,min,max; 5 | while(cin>>t>>min>>max){ 6 | int count=0; 7 | while(t--){ 8 | int a; 9 | cin>>a; 10 | if(a>=min&&a<=max) count++; 11 | } 12 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int x[10]; 7 | int z; 8 | cin>>z; 9 | for(int i=0;i<10;i++) 10 | { 11 | x[i]=z; 12 | z=z*2; 13 | } 14 | for(int i=0;i<10;i++) 15 | { 16 | 17 | printf("N[%d] = %d\n",i,x[i]); 18 | } 19 | 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /1436.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | for(int i=1;i<=n;i++) 8 | { 9 | int a[12]; 10 | int N; 11 | cin>>N; 12 | for(int j=0;j>a[j]; 15 | } 16 | cout<<"Case "< 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | int y; 10 | cin>>y; 11 | if(y>=2015) 12 | { 13 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int t,n; 6 | int r=0,R=0; 7 | cin>>t; 8 | for(int i=1;i<=t;i++) 9 | { 10 | cin>>n; 11 | if(n>=10&&n<=20) 12 | { 13 | r++; 14 | } 15 | else 16 | R++; 17 | } 18 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | double a; 8 | double z=0.0; 9 | int count=0; 10 | while(1) 11 | { 12 | cin>>a; 13 | if(a<0) 14 | break; 15 | count++; 16 | z=z+a; 17 | } 18 | z=z/count; 19 | printf("%.2lf\n",z); 20 | 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /1467.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c; 6 | while(cin>>a>>b>>c) 7 | { 8 | if(a==b&&a==c) 9 | cout<<"*\n"; 10 | else 11 | { 12 | if(a==b)cout<<"C\n"; 13 | else if(a==c)cout<<"B\n"; 14 | else if(b==c)cout<<"A\n"; 15 | } 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /2176.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | string str; 6 | cin>>str; 7 | int count=0; 8 | for(int i=0;i 2 | using namespace std; 3 | int main(){ 4 | string str; 5 | cin>>str; 6 | for(int i=0;i=65&&str[i]<=90)str[i]=str[i]+32; 9 | } 10 | size_t found = str.find("zelda"); 11 | if(found!=std::string::npos)cout<<"Link Bolado\n"; 12 | else cout<<"Link Tranquilo\n"; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /1117.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | float av=0.0; 6 | int I=0; 7 | float x; 8 | while(I<2) 9 | { 10 | cin>>x; 11 | if(x>=0.0&&x<=10.00) 12 | { 13 | av+=x; 14 | I++; 15 | } 16 | else cout<<"nota invalida\n"; 17 | } 18 | printf("media = %.2f\n",av/2.00); 19 | } 20 | -------------------------------------------------------------------------------- /1893.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int i, f; 6 | 7 | scanf( "%d%d", &i, &f ); 8 | if( 3 <= f && f <= 96 && f > i ) printf( "crescente\n" ); 9 | else if( 3 <= f && f <= 96 && f < i ) printf( "minguante\n" ); 10 | else if( 0 <= f && f <= 2 ) printf( "nova\n" ); 11 | else if( 97 <= f && f <= 100 ) printf( "cheia\n" ); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /1929.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a[4]; 6 | for(int i=0;i<4;i++) 7 | cin>>a[i]; 8 | sort(a,a+4); 9 | if(a[0]+a[1]>a[2]) 10 | cout<<"S\n"; 11 | else if(a[0]+a[2]>a[3]) 12 | cout<<"S\n"; 13 | else if(a[1]+a[2]>a[3]) 14 | cout<<"S\n"; 15 | else 16 | cout<<"N\n"; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /1036.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main() 5 | { 6 | double a,b,c,r1,r2,d; 7 | scanf("%lf %lf %lf",&a,&b,&c); 8 | d=(pow(b,2)-(4*a*c)); 9 | r1=(-b+sqrt(d))/(2*a); 10 | r2=(-b-sqrt(d))/(2*a); 11 | if(a!=0 && d>0) 12 | { 13 | printf("R1 = %.5lf\nR2 = %.5lf\n",r1,r2); 14 | } 15 | else{ 16 | printf("Impossivel calcular\n"); 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /1114.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int x; 8 | for(;;) 9 | { 10 | cin>>x; 11 | if(x==2002) 12 | { 13 | cout<<"Acesso Permitido\n"; 14 | break; 15 | } 16 | else 17 | { 18 | cout<<"Senha Invalida\n"; 19 | } 20 | } 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /1984.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | /** 8 | * Escreva a sua solução aqui 9 | * Code your solution here 10 | * Escriba su solución aquí 11 | */ 12 | string str; 13 | cin>>str; 14 | for(int i=str.length()-1;i>=0;i--) 15 | cout< 2 | using namespace std; 3 | int main(){ 4 | int a; 5 | while(cin>>a){ 6 | if(a==1) 7 | cout<<0<a) 15 | break; 16 | if(sum==a) 17 | break; 18 | } 19 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int n[20],m[20]; 8 | for(int i=0;i<20;i++) 9 | { 10 | cin>>n[i]; 11 | } 12 | for(int i=0,j=19;i<20;i++,j--) 13 | { 14 | m[i]=n[j]; 15 | } 16 | for(int i=0;i<20;i++) 17 | { 18 | printf("N[%d] = %d\n",i,m[i]); 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /1178.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | double x[100]; 8 | double z; 9 | cin>>z; 10 | for(int i=0;i<100;i++) 11 | { 12 | x[i]=z; 13 | z=z/2.0000; 14 | } 15 | for(int i=0;i<100;i++) 16 | { 17 | 18 | printf("N[%d] = %.4lf\n",i,x[i]); 19 | } 20 | 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /1393.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define ll long long 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | ll n; 8 | while(cin>>n&&n) 9 | { 10 | ll _0=0,_1=1; 11 | ll ans=0; 12 | for(ll i=1;i<=n;i++) 13 | { 14 | ans=_0+_1; 15 | _0=_1; 16 | _1=ans; 17 | } 18 | printf("%d\n",ans); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /1038.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int X,Y; 8 | float Z; 9 | cin>>X>>Y; 10 | if(X==1) 11 | Z=Y*4.00; 12 | if(X==2) 13 | Z=Y*4.50; 14 | if(X==3) 15 | Z=Y*5.00; 16 | if(X==4) 17 | Z=Y*2.00; 18 | if(X==5) 19 | Z=Y*1.50; 20 | printf("Total: R$ %.2f\n",Z); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /1064.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | float x,y=0; 7 | int c=0; 8 | for(int i=1;i<=6;i++) 9 | { 10 | cin>>x; 11 | if(x>0) 12 | { 13 | y=y+x; 14 | c++; 15 | } 16 | } 17 | y=y/c; 18 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a,b; 8 | int sum=0; 9 | cin>>a>>b; 10 | if(b 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int count=0; 8 | for(int i=1,j=7;;j--,count++) 9 | { 10 | if(count!=0&&count%3==0) 11 | { 12 | i+=2; 13 | j=7; 14 | } 15 | cout<<"I="< 2 | using namespace std; 3 | int main(){ 4 | int n[100]; 5 | int q; 6 | int N,Q; 7 | while(cin>>N>>Q) 8 | { 9 | for(int i=0;i>n[i]; 11 | sort(n,n+N,greater()); 12 | for(int i=0;i>q; 15 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | double vol,rad,area,height; 8 | while(scanf("%lf %lf", &vol ,&rad)!=EOF) 9 | { 10 | rad=rad/2; 11 | area=3.14*rad*rad; 12 | height=vol/(3.14*rad*rad); 13 | printf("ALTURA = %.2lf\n",height); 14 | printf("AREA = %.2lf\n",area); 15 | 16 | } 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /1012.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | double a,b,c,p,pi=3.14159,tri,cir,tra,square,rect; 6 | while(scanf("%lf %lf %lf",&a,&b,&c)==3){ 7 | tri=a*c/2; 8 | cir=pi*c*c; 9 | p=a+b; 10 | tra=.5*p*c; 11 | square=(b*b); 12 | rect=a*b; 13 | printf("TRIANGULO: %.3lf\nCIRCULO: %.3lf\nTRAPEZIO: %.3lf\nQUADRADO: %.3lf\nRETANGULO: %.3lf\n",tri,cir,tra,square,rect); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /1142.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int level,l=1; 8 | cin>>level; 9 | for(int i=1;i<=level;i++) 10 | { 11 | for(int j=1;j<=4;j++,l++) 12 | { 13 | if(j%4==0) 14 | cout<<"PUM\n"; 15 | 16 | else 17 | { 18 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string a; 6 | int mid,t,i; 7 | cin>>t; 8 | cin.ignore(); 9 | for(int j=1;j<=t;j++) 10 | { 11 | getline(cin,a); 12 | for(i=(a.length()/2)-1;i>=0;i--) 13 | cout<=a.length()/2;i--) 15 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int x,y; 8 | cin>>x>>y; 9 | if(y>x){ 10 | for(int i=x+1;iy){ 17 | for(int i=y+1;i 2 | using namespace std; 3 | int main() 4 | { 5 | int chicken1,beef1,pasta1; 6 | int chicken2,beef2,pasta2; 7 | scanf("%d%d%d",&chicken1,&beef1,&pasta1); 8 | scanf("%d%d%d",&chicken2,&beef2,&pasta2); 9 | int miss=0; 10 | if(chicken2>chicken1)miss+=(chicken2-chicken1); 11 | if(beef2>beef1)miss+=(beef2-beef1); 12 | if(pasta2>pasta1)miss+=(pasta2-pasta1); 13 | printf("%d\n",miss); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /1157.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | /** 8 | * Escreva a sua solução aqui 9 | * Code your solution here 10 | * Escriba su solución aquí 11 | */ 12 | int t; 13 | cin>>t; 14 | cout<<1< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | while(n!=0) 8 | { 9 | int sum1=0,sum2=0; 10 | int a,b; 11 | while(n-->0) 12 | { 13 | cin>>a>>b; 14 | if(a>b) 15 | sum1+=1; 16 | if(b>a) 17 | sum2+=1; 18 | } 19 | cout<>n; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /1858.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | int a[n]; 8 | for(int i=0;i>a[i]; 11 | } 12 | int small=a[0]; 13 | int index=0; 14 | for(int i=1;i 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | string str; 12 | cin>>str; 13 | string c; 14 | for(int i=str.length()-1,j=0;i>=0;i--,j++) 15 | c[j]=str[i]; 16 | if(c==str) 17 | cout<<"N\n"; 18 | else 19 | cout<<"Y\n"; 20 | } 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /2523.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string message; 8 | while(cin>>message) 9 | { 10 | int numberOfCommands; 11 | cin>>numberOfCommands; 12 | int index; 13 | for(int inner=0;inner>index;cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a[100]; 8 | int h,p; 9 | for(int i=0;i<100;i++) 10 | { 11 | cin>>a[i]; 12 | } 13 | h=a[0]; 14 | p=0; 15 | for(int i=0;i<99;i++) 16 | { 17 | if(a[i+1]>h) 18 | { 19 | h=a[i+1]; 20 | p=i+1; 21 | } 22 | } 23 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | int a[n]; 8 | a[0]=0; 9 | a[1]=1; 10 | for(int i=2;i 2 | using namespace std; 3 | int gcd(int a, int b) { 4 | return (b == 0 ? a : gcd(b, a % b)); 5 | } 6 | int main() 7 | { 8 | int yearPast; 9 | int L1,L2,L3; 10 | while(cin>>yearPast) 11 | { 12 | cin>>L1>>L2>>L3; 13 | int g=gcd(L1,L2); 14 | g=(L1*L2)/g; 15 | int c=gcd(g,L3); 16 | int yearsComing=(L3*g)/c; 17 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | float a[12][12]; 6 | string c; 7 | cin>>c; 8 | float ad=0.0; 9 | for(int i=0;i<12;i++) 10 | { 11 | for(int j=0;j<12;j++) 12 | { 13 | cin>>a[i][j]; 14 | if(j>i) 15 | ad+=a[i][j]; 16 | } 17 | } 18 | if(c=="S")printf("%.1f\n",ad); 19 | else printf("%.1f\n",ad/66); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /1184.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | float a[12][12]; 6 | string c; 7 | cin>>c; 8 | float ad=0.0; 9 | for(int i=0;i<12;i++) 10 | { 11 | for(int j=0;j<12;j++) 12 | { 13 | cin>>a[i][j]; 14 | if(j 2 | using namespace std; 3 | int main() 4 | { 5 | int N; 6 | int hours=0,minutes=0,seconds=0; 7 | cin>>N; 8 | if(N>=60) 9 | { 10 | minutes=N/60; 11 | N=N%60; 12 | } 13 | if(N>=1){ 14 | seconds=N; 15 | } 16 | if(minutes>=60) 17 | { 18 | hours=minutes/60; 19 | minutes=minutes%60; 20 | } 21 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int N; 6 | cin>>N; 7 | int year=0,month=0,day=0; 8 | if(N>=365) 9 | { 10 | year=N/365; 11 | N=N%365; 12 | } 13 | if(N>=30) 14 | { 15 | month=N/30; 16 | N=N%30; 17 | } 18 | day=N; 19 | printf("%d ano(s)\n",year); 20 | printf("%d mes(es)\n",month); 21 | printf("%d dia(s)\n",day); 22 | return 0; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /1414.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int T,N; 7 | while(cin>>T>>N&&T) 8 | { 9 | int totalPoints=3*N; 10 | int matchDraw=0; 11 | for(int i=0;i>str>>point; 16 | matchDraw+=point; 17 | } 18 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string str; 6 | int len; 7 | while(cin>>len>>str) 8 | { 9 | long long sum=0; 10 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | double x,y; 7 | int i=1; 8 | while(cin>>x>>y){ 9 | double z,Y; 10 | Y=y-x; 11 | //z=Y*100; 12 | //z=z/y; 13 | z=(Y*100)/x*1.00; 14 | cout<<"Projeto "< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a,b; 8 | while(1) 9 | { 10 | cin>>a>>b; 11 | if(a==0||b==0) 12 | break; 13 | if(a>0&&b>0) 14 | cout<<"primeiro\n"; 15 | if(a>0&&b<0) 16 | cout<<"quarto\n"; 17 | if(a<0&&b<0) 18 | cout<<"terceiro\n"; 19 | if(a<0&&b>0) 20 | cout<<"segundo\n"; 21 | 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /1743.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a[5],b[5]; 6 | for(int i=0;i<5;i++) 7 | cin>>a[i]; 8 | for(int i=0;i<5;i++) 9 | cin>>b[i]; 10 | int i=0; 11 | bool x=true; 12 | while(i<5) 13 | { 14 | if(a[i]==b[i]) 15 | { 16 | x=false; 17 | break; 18 | } 19 | i++; 20 | } 21 | if(x) 22 | cout<<"Y\n"; 23 | else 24 | cout<<"N\n"; 25 | } 26 | -------------------------------------------------------------------------------- /1134.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,m=0,n=0,k=0; 6 | while(1) 7 | { 8 | cin>>a; 9 | if(a==1) 10 | m++; 11 | if(a==2) 12 | n++; 13 | if(a==3) 14 | k++; 15 | if(a==4) 16 | break; 17 | 18 | 19 | }cout<<"MUITO OBRIGADO\n"; 20 | cout<<"Alcool: "< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | int a,c1=0,c2=0; 10 | for(int i=0;i>a; 13 | if(a==0) 14 | c1++; 15 | if(a==1) 16 | c2++; 17 | 18 | } 19 | if(c1>c2) 20 | cout<<"Y"<0){ 10 | String id1; 11 | id1=sc.nextLine(); 12 | number--; 13 | System.out.println("I am Toorg!"); 14 | } 15 | } 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /1116.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n; 7 | double x,y,z; 8 | cin>>n; 9 | for(int i=1;i<=n;i++) 10 | { 11 | 12 | cin>>x>>y; 13 | if(y==0) 14 | { 15 | 16 | cout<<"divisao impossivel\n"; 17 | } 18 | else 19 | { 20 | z=(double)x/y; 21 | 22 | printf("%.1lf\n",z); 23 | } 24 | 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /1182.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | float a[12][12]; 6 | char c; 7 | int column; 8 | cin>>column; 9 | cin>>c; 10 | float ad=0.0; 11 | for(int i=0;i<12;i++) 12 | { 13 | for(int j=0;j<12;j++) 14 | { 15 | cin>>a[i][j]; 16 | if(j==column)ad+=a[i][j]; 17 | } 18 | } 19 | if(c=='s')printf("%.1f\n",ad); 20 | else printf("%.1f\n",ad/12); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /1198.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int diff; 8 | long long a,b; 9 | while(scanf("%lld%lld",&a,&b)!=EOF) 10 | { 11 | long long small,large; 12 | if(a<=b) 13 | { 14 | small=a; 15 | large=b; 16 | } 17 | else 18 | { 19 | small=b; 20 | large=a; 21 | } 22 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a; 8 | cin>>a; 9 | if(a<=1) 10 | cout<<"Top 1\n"; 11 | if(a>1&&a<=3) 12 | cout<<"Top 3\n"; 13 | if(a>3&&a<=5) 14 | cout<<"Top 5\n"; 15 | if(a>5&&a<=10) 16 | cout<<"Top 10\n"; 17 | if(a>10&&a<=25) 18 | cout<<"Top 25\n"; 19 | if(a>25&&a<=50) 20 | cout<<"Top 50\n"; 21 | if(a>50&&a<=100) 22 | cout<<"Top 100\n"; 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /2167.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t,b=0,a[200]; 8 | cin>>t; 9 | for(int i=0;i>a[i]; 12 | } 13 | bool x=true; 14 | for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | int x,sum=0,m; 8 | while(t>0) 9 | { 10 | cin>>x; 11 | m=x/2; 12 | for(int i=1;i<=m;i++) 13 | { 14 | if(x%i==0) 15 | sum=sum+i; 16 | } 17 | if(sum==x) 18 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | int n; 10 | cin>>n; 11 | seta; 12 | //set::iterator x; 13 | for(int i=0;i>y; 16 | a.insert(y); 17 | 18 | } 19 | int count; 20 | count=a.size(); 21 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int n; 8 | cin>>n; 9 | while(n-->0) 10 | { 11 | int t; 12 | cin>>t; 13 | while(t-->0) 14 | { 15 | int x; 16 | cin>>x; 17 | if(x==1) 18 | cout<<"Rolien\n"; 19 | if(x==2) 20 | cout<<"Naej\n"; 21 | if(x==3) 22 | cout<<"Elehcim\n"; 23 | if(x==4) 24 | cout<<"Odranoel\n"; 25 | } 26 | } 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2242.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | string x,y,z; 6 | cin>>x; 7 | for(int i=0;i=0;i--){ 12 | if(x[i]=='a'||x[i]=='e'||x[i]=='i'||x[i]=='o'||x[i]=='u') 13 | z=z+x[i]; 14 | } 15 | if(y==z) 16 | cout<<"S\n"; 17 | else 18 | cout<<"N\n"; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /2540.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | int m; 7 | while(cin>>n) 8 | { 9 | int _1=0; 10 | for(int i=0;i>m; 13 | if(m) 14 | _1++; 15 | } 16 | float M=ceil(n*.666); 17 | int x=(int) M; 18 | if(_1>=x) 19 | cout<<"impeachment\n"; 20 | else cout<<"acusacao arquivada\n"; 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /1329.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int n; 8 | cin>>n; 9 | while(n!=0) 10 | { 11 | int r; 12 | int m=0,a=0; 13 | for(int i=1;i<=n;i++) 14 | { 15 | cin>>r; 16 | if(r==0) 17 | m+=1; 18 | else 19 | a+=1; 20 | } 21 | cout<<"Mary won "<>n; 23 | } 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /2150.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | string x,y; 8 | while(cin>>x) 9 | { 10 | cin.ignore(); 11 | getline(cin,y); 12 | int count=0; 13 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int z; 7 | while(1) 8 | { 9 | cin>>z; 10 | if(z==0) 11 | break; 12 | for(int i=1;i<=z;i++) 13 | { 14 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | /** 8 | * Escreva a sua solução aqui 9 | * Code your solution here 10 | * Escriba su solución aquí 11 | */ 12 | double x[100]; 13 | int i; 14 | for(i=0;i<100;i++) 15 | { 16 | scanf("%lf",&x[i]); 17 | } 18 | for(i=0;i<100;i++) 19 | { 20 | if(x[i]<=10.0) 21 | printf("A[%d] = %.1lf\n",i,x[i]); 22 | } 23 | 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /1332.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | char s[6]; 9 | scanf("%d",&n); 10 | while(n--){ 11 | 12 | scanf("%s",&s); 13 | if(strlen(s)==5) 14 | { 15 | printf("3\n"); 16 | }else if((s[0]=='t' && s[1]=='w')||(s[0]=='t'&&s[2]=='o')||(s[1]=='w'&&s[2]=='o')){ 17 | printf("2\n"); 18 | } 19 | else 20 | printf("1\n"); 21 | } 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /2592.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | while(cin>>n&&n) 7 | { 8 | 9 | int c=0; 10 | while(true) 11 | { 12 | bool f=false; 13 | int x; 14 | for(int i=1;i<=n;i++) 15 | { 16 | cin>>x; 17 | if(x!=i) f=true; 18 | } 19 | c++; 20 | if(!f) break; 21 | } 22 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | int a,b,c; 12 | cin>>a>>b>>c; 13 | if(a<10) 14 | cout<<"0"; 15 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c,d=0,e,f; 6 | cin>>a>>b>>e>>f; 7 | if(a>e) 8 | { 9 | c=24-a+e; 10 | } 11 | if(ab) 20 | { 21 | d=f-b; 22 | } 23 | if(f 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int x,y,t; 8 | cin>>t; 9 | while(t>0){ 10 | cin>>x>>y; 11 | int sum=0,c=0; 12 | for(int i=x;;i++) 13 | { 14 | if(c==y) 15 | break; 16 | if(i%2!=0) 17 | { 18 | sum=sum+i; 19 | c++; 20 | } 21 | } 22 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | char c; 8 | double a[12][12]; 9 | double sum=0; 10 | cin>>c; 11 | for(int i=0;i<12;i++) 12 | { 13 | for(int j=0;j<12;j++) 14 | { 15 | cin>>a[i][j]; 16 | } 17 | } 18 | for(int i=7;i<12;i++) 19 | { 20 | for(int j=12-i;j 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int x; 8 | while(true) 9 | { 10 | cin>>x; 11 | if(x==0) 12 | break; 13 | int sum=0,c=0; 14 | for(int i=x;;i++) 15 | { 16 | if(c==5) 17 | break; 18 | if(i%2==0) 19 | { 20 | sum=sum+i; 21 | c++; 22 | } 23 | } 24 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int n,l,p; 8 | cin>>n; 9 | int a[n]; 10 | for(int i=0;i>a[i]; 13 | } 14 | l=a[0]; 15 | p=0; 16 | for(int i=1;i 2 | using namespace std; 3 | int main(){ 4 | int a; 5 | cin>>a; 6 | while(a--){ 7 | string p; 8 | cin>>p; 9 | cout<<"k"; 10 | int count=0; 11 | int pos; 12 | for(int i=1;i 2 | using namespace std; 3 | int main() 4 | { 5 | string str; 6 | getline(cin,str); 7 | stringstream f(str); 8 | string temp; 9 | int count=1; 10 | while(f>>temp) 11 | { 12 | if(count++!=1)cout<<" "; 13 | if(temp.length()<=3) 14 | { 15 | cout< 2 | 3 | int main(){ 4 | int x1,y1,x2,y2; 5 | 6 | while(true){ 7 | scanf("%d %d %d %d",&x1,&y1,&x2,&y2); 8 | if(x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0) break; 9 | 10 | if(x1 == x2 && y1 == y2) printf("0\n"); 11 | else if(abs(x2-x1) == abs(y2-y1)) 12 | printf("1\n"); 13 | else if(x1 == x2 || y1 == y2) printf("1\n"); 14 | else printf("2\n"); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /1165.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | bool isPrime(int n) 4 | { 5 | if(n==0||n==1)return false; 6 | else if(n==2)return true; 7 | else if(n%2==0)return false; 8 | for(int i=3;i<=sqrt(n);i++) 9 | { 10 | if(n%i==0)return false; 11 | } 12 | return true; 13 | } 14 | int main() 15 | { 16 | int n; 17 | cin>>n; 18 | while(n--) 19 | { 20 | int x; 21 | cin>>x; 22 | if(isPrime(x))cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | float m[12][12]; 8 | int index; 9 | char c; 10 | cin>>index; 11 | cin>>c; 12 | for(int i=0;i<12;i++) 13 | { 14 | for(int j=0;j<12;j++) 15 | { 16 | cin>>m[i][j]; 17 | } 18 | } 19 | float sum=0.0; 20 | for(int i=0;i<12;i++) 21 | { 22 | sum=sum+m[index][i]; 23 | } 24 | if(c=='S') 25 | printf("%.1f\n",sum); 26 | if(c=='M') 27 | printf("%.1f\n",sum/12); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /1221.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | bool isPrime(int number) 5 | { 6 | if(number==2)return true; 7 | else if(number%2==0)return false; 8 | else{ 9 | for(int i=3;i<=sqrt(number);i+=2) 10 | { 11 | if(number%i==0)return false; 12 | } 13 | } 14 | return true; 15 | } 16 | int main() 17 | { 18 | int t; 19 | cin>>t; 20 | while(t--) 21 | { 22 | int f; 23 | cin>>f; 24 | if(isPrime(f))cout<<"Prime\n"; 25 | else cout<<"Not Prime\n"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /2166.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | double x=0.0; 7 | int n; 8 | cin>>n; 9 | if(n==1) 10 | x=0.5000000000; 11 | if(n==0) 12 | x=0.0000000000; 13 | for(int i=2;i<=n;i++) 14 | { 15 | if(i==2) 16 | { 17 | x=2.0+.5; 18 | x=1.0/x; 19 | } 20 | else 21 | { 22 | x=2.0+x; 23 | x=1.0/x; 24 | } 25 | 26 | } 27 | x=x+1.00; 28 | printf("%.10lf\n",x); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /2149.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define for(i,n) for(i;i>n) 8 | { 9 | long long a[100]; 10 | a[0]=0; 11 | a[1]=1; 12 | int i=2; 13 | for(i,n) 14 | { 15 | if(i%2==0) 16 | { 17 | a[i]=a[i-1]+a[i-2]; 18 | } 19 | else 20 | { 21 | a[i]=a[i-1]*a[i-2]; 22 | } 23 | } 24 | cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | double x=0.0; 7 | int n; 8 | cin>>n; 9 | if(n==1) 10 | x=0.1666666667; 11 | if(n==0) 12 | x=0.0000000000; 13 | for(int i=2;i<=n;i++) 14 | { 15 | if(i==2) 16 | { 17 | x=6.0+(1.00/6.00); 18 | x=1.0/x; 19 | } 20 | else 21 | { 22 | x=6.00+x; 23 | x=1.0/x; 24 | } 25 | 26 | } 27 | x=x+3.00; 28 | printf("%.10lf\n",x); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /1035.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int a,b,c,d; 7 | bool x=false,y=false,z=false,k=false,l=false; 8 | cin>>a>>b>>c>>d; 9 | if(b>c&&d>a) 10 | { 11 | x=true; 12 | } 13 | if(c+d>a+b) 14 | { 15 | y=true; 16 | } 17 | if(c>0&&d>0) 18 | { 19 | z=true; 20 | } 21 | if(a%2==0) 22 | { 23 | k=true; 24 | } 25 | if(x&&y&&z&&k) 26 | { 27 | l=true; 28 | } 29 | if(l) 30 | { 31 | cout<<"Valores aceitos\n"; 32 | } 33 | else 34 | { 35 | cout<<"Valores nao aceitos\n"; 36 | } 37 | return 0; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /2129.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | int dig[] = {1, 1, 2, 6, 4, 2, 2, 4, 2, 8}; 6 | 7 | int lastNon0Digit(int n) 8 | { 9 | if (n < 10) 10 | return dig[n]; 11 | if (((n/10)%10)%2 == 0) 12 | return (6*lastNon0Digit(n/5)*dig[n%10]) % 10; 13 | else 14 | return (4*lastNon0Digit(n/5)*dig[n%10]) % 10; 15 | } 16 | int main() 17 | { 18 | int n; 19 | int I=1; 20 | while(cin>>n) 21 | { 22 | printf("Instancia %d\n",I++); 23 | printf("%d\n\n",lastNon0Digit(n)); 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /2174.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int i,j,k,n; 6 | scanf("%d",&n); 7 | string a[n]; 8 | for(i=0;i>a[i]; 10 | 11 | for(i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--){ 8 | int rows,coef=1,space,i,j; 9 | cin>>rows; 10 | long long sum=0; 11 | if(rows==31) 12 | cout<<"2147483647\n"; 13 | else{ 14 | for(i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | while(n--) 8 | { 9 | string str; 10 | float deg; 11 | cin>>str; 12 | cin>>deg; 13 | float a[7],sum=0; 14 | for(int i=0;i<7;i++) 15 | { 16 | cin>>a[i]; 17 | sum=sum+a[i]; 18 | } 19 | sort(a,a+7); 20 | sum=sum-a[0]; 21 | sum=sum-a[6]; 22 | sum=sum*deg; 23 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | int _2=0,_3=0,_4=0,_5=0; 10 | while(t-->0){ 11 | int x; 12 | cin>>x; 13 | if(x%2==0) 14 | _2++; 15 | if(x%3==0) 16 | _3++; 17 | if(x%4==0) 18 | _4++; 19 | if(x%5==0) 20 | _5++; 21 | } 22 | cout<<_2<<" Multiplo(s) de 2\n"; 23 | cout<<_3<<" Multiplo(s) de 3\n"; 24 | cout<<_4<<" Multiplo(s) de 4\n"; 25 | cout<<_5<<" Multiplo(s) de 5\n"; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /1069.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main(){ 5 | string x; 6 | int N; 7 | cin>>N; 8 | cin.ignore(); 9 | while(N-->0) 10 | { 11 | cin>>x; 12 | int i,j,k,flag=0; 13 | for(i=0,j=0,k=0;i'){ 19 | if(j > 0){ 20 | k++; 21 | j--; 22 | } 23 | } 24 | } 25 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | string s, tmp; 9 | bool check; 10 | 11 | cin >> n; cin.ignore(); 12 | 13 | for (int i = 0; i < n; ++i) 14 | { 15 | cin >> k; cin.ignore(); 16 | check = false; 17 | 18 | for (int j = 0; j < k; ++j) 19 | { 20 | getline(cin, s); 21 | if(j == 0) 22 | tmp = s; 23 | 24 | if(tmp != s) 25 | check = true; 26 | } 27 | 28 | if(check){ 29 | cout << "ingles" << '\n'; 30 | }else{ 31 | cout << s << '\n'; 32 | } 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /1953.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | while(cin>>t) 9 | { 10 | int e=0,f=0,c=0; 11 | while(t-->0) 12 | { 13 | int x; 14 | string y; 15 | cin>>x>>y; 16 | if(y=="EPR") 17 | e++; 18 | else if(y=="EHD") 19 | f++; 20 | else 21 | c++; 22 | 23 | 24 | } 25 | cout<<"EPR: "<0){ 11 | int id1,num; 12 | id1=sc.nextInt(); 13 | num=sc.nextInt(); 14 | if(id==id1&&num==0) 15 | count++; 16 | number--; 17 | } 18 | System.out.println(count); 19 | } 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /2863.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | #define all(v) v.begin(),v.end() 16 | 17 | typedef long long ll; 18 | int main() 19 | { 20 | int t; 21 | double n; 22 | while(cin>>t) 23 | { 24 | double less=12.00; 25 | while(t--){ 26 | cin>>n; 27 | if(n 2 | #include 3 | 4 | using namespace std; 5 | int main() 6 | { 7 | int n; 8 | cin>>n; 9 | int a[n],b[n]; 10 | int o=0,e=0,x; 11 | for(int i=0;i>x; 14 | if(x%2==0) 15 | { 16 | b[e++]=x; 17 | } 18 | else 19 | { 20 | a[o++]=x; 21 | } 22 | } 23 | sort(b,b+e); 24 | sort(a,a+o,greater()); 25 | for(int i=0;i 2 | using namespace std; 3 | #define pi 3.141592653589793 4 | int main() 5 | { 6 | //freopen("c.txt","w",stdout); 7 | vector a(3); 8 | while(cin>>a[0]>>a[1]>>a[2]) 9 | { 10 | sort(a.begin(),a.end()); 11 | if(a[0]+a[1]>a[2]) 12 | { 13 | double s=(a[0]+a[1]+a[2])/2.00; 14 | double area=sqrt(s*(s-a[0])*(s-a[1])*(s-a[2])); 15 | area=4*area/3; 16 | printf("%.3lf\n",area); 17 | } 18 | else 19 | { 20 | printf("-1.000\n"); 21 | } 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /2484.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | string str; 6 | while(cin>>str) 7 | { 8 | int j=0; 9 | int k=str.length(); 10 | for(int counter=0;counter 2 | using namespace std; 3 | int main(){ 4 | int t; 5 | cin>>t; 6 | while(t--){ 7 | int n; 8 | cin>>n; 9 | string d; 10 | cin>>d; 11 | int l=d.length(); 12 | string c=d; 13 | sort(c.begin(),c.end()); 14 | int count=0; 15 | for(int i=0;i2) 19 | break; 20 | } 21 | if(count==2) cout<<"There are the chance.\n"; 22 | else cout<<"There aren't the chance.\n"; 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /1029.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int fibo(int a,int& call) 4 | { 5 | int sum1=0; 6 | call++; 7 | if(a==0) 8 | return 0; 9 | else if(a==1) 10 | return 1; 11 | else 12 | { 13 | sum1=fibo(a-1,call)+fibo(a-2,call); 14 | } 15 | return sum1; 16 | 17 | } 18 | int main() 19 | { 20 | int t; 21 | cin>>t; 22 | while(t--) 23 | { 24 | int x; 25 | cin>>x; 26 | int sum=0,call=-1; 27 | sum=fibo(x,call); 28 | printf("fib(%d) = %d calls = %d\n",x,call,sum); 29 | } 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /1176.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | int t; 7 | cin>>t; 8 | while(t--) 9 | { 10 | ll n; 11 | cin>>n; 12 | if(n==0)cout<<"Fib(0) = 0\n"; 13 | else if(n==1)cout<<"Fib(1) = 1\n"; 14 | else{ 15 | ll pred=0; 16 | ll before=1; 17 | ll k; 18 | for(int i=2;i<=n;i++) 19 | { 20 | k=pred+before; 21 | pred=before; 22 | before=k; 23 | } 24 | printf("Fib(%d) = ",n); 25 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | float x; 6 | cin>>x; 7 | if(x>=0&&x<=100){ 8 | if(x>=0.0000&&x<=25.0000) 9 | { 10 | cout<<"Intervalo [0,25]\n"; 11 | } 12 | if(x>25.0000&&x<=50.0000) 13 | { 14 | cout<<"Intervalo (25,50]\n"; 15 | } 16 | if(x>50.0000&&x<=75.0000) 17 | { 18 | cout<<"Intervalo (50,75]\n"; 19 | } 20 | if(x>75.0000&&x<=100.0000) 21 | { 22 | cout<<"Intervalo (75,100]\n"; 23 | } 24 | } 25 | else 26 | { 27 | cout<<"Fora de intervalo\n"; 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /2753.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | for(int i=97;i<=122;i++) 28 | { 29 | printf("%d e %c\n",i,i); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /2762.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | ll a,b; 28 | scanf("%lld.%lld",&a,&b); 29 | printf("%lld.%lld\n",b,a); 30 | } 31 | -------------------------------------------------------------------------------- /2663.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | int k; 7 | cin>>n; 8 | cin>>k; 9 | vector a(n); 10 | for(int i=0;i>a[i]; 12 | sort(a.begin(),a.end(),greater()); 13 | int count=0; 14 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n; 7 | cin>>n; 8 | cin.ignore(); 9 | while(n--) 10 | { 11 | int N; 12 | cin>>N; 13 | int a[N],b[N]; 14 | for(int i=0;i>a[i]; 17 | b[i]=a[i]; 18 | } 19 | sort(a,a+N,greater()); 20 | int count=0; 21 | for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | float x,y; 6 | cin>>x>>y; 7 | if(x==0&&y==0) 8 | { 9 | cout<<"Origem\n"; 10 | } 11 | if(x>0&&y>0) 12 | { 13 | cout<<"Q1\n"; 14 | } 15 | if(x<0&&y>0) 16 | { 17 | cout<<"Q2\n"; 18 | 19 | } 20 | if(x<0&&y<0) 21 | { 22 | cout<<"Q3\n"; 23 | } 24 | if(x>0&&y<0) 25 | { 26 | cout<<"Q4\n"; 27 | } 28 | if((x>0||x<0)&&y==0) 29 | { 30 | cout<<"Eixo X\n"; 31 | } 32 | if((y>0||y<0)&&x==0) 33 | { 34 | cout<<"Eixo Y\n"; 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /1071.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a,b; 8 | cin>>a>>b; 9 | int sum=0; 10 | if(a>b) 11 | { 12 | for(int i=a-1;i>b;i--) 13 | { 14 | if(i%2!=0) 15 | { 16 | sum=sum+i; 17 | } 18 | } 19 | } 20 | else if(a 2 | using namespace std; 3 | int main() 4 | { 5 | int n,b; 6 | while(cin>>n>>b&&n) 7 | { 8 | vector a(n+1); 9 | int count=n+1; 10 | std::fill(a.begin(),a.end(),false); 11 | vector c(b); 12 | for(int i=0;i>c[i]; 15 | a[c[i]]=true; 16 | count--; 17 | } 18 | int abss; 19 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int x,y,flag=0,sum; 8 | cin>>x>>y; 9 | int a[120]; 10 | for(int i=0;i>a[i]; 13 | } 14 | for(int i=1;ia[i-1]) 17 | sum = (a[i] - a[i-1]); 18 | else 19 | sum = (a[i-1] - a[i]); 20 | if(sum<=x) 21 | flag=1; 22 | else 23 | { 24 | flag=0; 25 | break; 26 | } 27 | } 28 | if(flag==1) 29 | cout<<"YOU WIN\n"; 30 | else 31 | cout<<"GAME OVER\n"; 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /1238.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | while(n--){ 8 | string x,y; 9 | cin>>x>>y; 10 | //if(x.length()>y.length()) 11 | //swap(x,y); 12 | string z; 13 | int i=0,I=x.length(); 14 | int j=0,J=y.length(); 15 | int k; 16 | for(i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int n; 8 | int a[500]; 9 | while((scanf("%d",&n))!=EOF) 10 | { 11 | for(int i=0;i>a[i]; 14 | } 15 | int big; 16 | big=a[0]; 17 | for(int i=1;ibig) 20 | big=a[i]; 21 | } 22 | if(big<10) 23 | cout<<1<=10&&big<20) 25 | cout<<2<=20) 27 | cout<<3< 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | int n; 10 | cin>>n; 11 | cin.ignore(); 12 | int pos=0; 13 | long long sum=0; 14 | for(int i=0;i>str; 18 | for(int j=0;j 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | char x[4]; 12 | int result,r[2]; 13 | cin>>x; 14 | r[0]=x[0]-48; 15 | r[1]=x[2]-48; 16 | if(isupper(x[1])) 17 | result=r[1]-r[0]; 18 | if(islower(x[1])&&x[0]==x[2]) 19 | result=r[1]*r[0]; 20 | if(isupper(x[1])&&x[0]==x[2]) 21 | result=r[1]*r[0]; 22 | if(islower(x[1])&&x[0]!=x[2]) 23 | result=r[0]+r[1]; 24 | printf("%d\n",result); 25 | 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /1429.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | string str; 6 | cin>>str; 7 | while(str!="0") 8 | { 9 | int n=str.length(); 10 | int a[n]; 11 | long long acm=0; 12 | int b[6]; 13 | b[4]=120; 14 | b[3]=24; 15 | b[2]=6; 16 | b[1]=2; 17 | b[0]=1; 18 | for(int i=0;i>str; 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /2766.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | string str; 28 | for(int i=1;i<=10;i++) 29 | { 30 | cin>>str; 31 | if(i==3||i==7||i==9)cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | string a,b; 10 | cin>>a>>b; 11 | if(b.length()>a.length()) 12 | { 13 | cout<<"nao encaixa\n"; 14 | } 15 | else{ 16 | int counter=0; 17 | for(int i=a.length()-1,j=b.length()-1;i>=0&&j>=0;i--,j--) 18 | { 19 | if(a[i]!=b[j])break; 20 | counter++; 21 | } 22 | if(counter==b.length()) 23 | cout<<"encaixa\n"; 24 | else cout<<"nao encaixa\n"; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1241.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | string a,b; 10 | cin>>a>>b; 11 | if(b.length()>a.length()) 12 | { 13 | cout<<"nao encaixa\n"; 14 | } 15 | else{ 16 | int counter=0; 17 | for(int i=a.length()-1,j=b.length()-1;i>=0&&j>=0;i--,j--) 18 | { 19 | if(a[i]!=b[j])break; 20 | counter++; 21 | } 22 | if(counter==b.length()) 23 | cout<<"encaixa\n"; 24 | else cout<<"nao encaixa\n"; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1214.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int t; 7 | cin>>t; 8 | while(t-->0) 9 | { 10 | int n; 11 | int x[1000]; 12 | int sum=0,count=0; 13 | double average,r; 14 | cin>>n; 15 | for(int i=0;i>x[i]; 18 | sum+=x[i]; 19 | 20 | } 21 | average=sum/n; 22 | for(int i=0;iaverage) 25 | count++; 26 | } 27 | r=(count*100)/(n*1.0); 28 | printf("%.3lf",r); 29 | cout<<"%\n"; 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /1410.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main(){ 5 | int n,m; 6 | while(cin>>n>>m){ 7 | if(n==0&&m==0) 8 | break; 9 | int attack[100],defend[100]; 10 | int i=0,j=0; 11 | for(i=0;i>attack[i]; 13 | sort(attack,attack+n); 14 | for(j=0;j>defend[j]; 16 | sort(defend,defend+m); 17 | if(attack[0]>=defend[0]&&attack[0]>=defend[1]) 18 | cout<<"N\n"; 19 | else if(attack[0]>=defend[1]) 20 | cout<<"N\n"; 21 | else 22 | cout<<"Y\n"; 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /1555.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | while(t-->0) 10 | { 11 | int a,b; 12 | cin>>a>>b; 13 | long long c[3],l; 14 | c[0]=(3*a*a*3)+(b*b); 15 | c[1]=2*(a*a)+(5*b*b*5); 16 | c[2]=(b*b*b)-(100*a); 17 | l=c[0]; 18 | for(int i=1;i<3;i++) 19 | { 20 | if(c[i]>l) 21 | l=c[i]; 22 | } 23 | if(l==c[0]) 24 | cout<<"Rafael ganhou\n"; 25 | else if(l==c[1]) 26 | cout<<"Beto ganhou\n"; 27 | else if(l==c[2]) 28 | cout<<"Carlos ganhou\n"; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /2180.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | bool isPrime(int a) 4 | { 5 | if(a%2==0)return false; 6 | for(int i=3;i<=sqrt(a);i=i+2) 7 | { 8 | if(a%i==0)return false; 9 | } 10 | return true; 11 | } 12 | int main() 13 | { 14 | long long a; 15 | cin>>a; 16 | long long v=0; 17 | int count=0; 18 | long long i=a; 19 | while(count<10) 20 | { 21 | if(isPrime(i)) 22 | { 23 | count++; 24 | v+=i; 25 | } 26 | i++; 27 | } 28 | int hour=60000000/v; 29 | int day=hour/24; 30 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n,m; 6 | cin>>n>>m; 7 | //cin.ignore(); 8 | string s; 9 | getline (cin, s); 10 | map mp; 11 | string x,y; 12 | char a,b; 13 | for(int i=0;i>x>>y; 16 | a=x[0]; 17 | b=y[0]; 18 | mp[a]=b; 19 | mp[b]=a; 20 | } 21 | //cin.ignore(); 22 | getline (cin, s); 23 | string str; 24 | map::iterator it; 25 | while(m--){ 26 | getline(cin,str); 27 | for(int i=0;isecond; 32 | else 33 | cout< 2 | using namespace std; 3 | int prime(int p) 4 | { 5 | if(p==2) 6 | return 2; 7 | else 8 | { 9 | int flag=0; 10 | for(int i=p;i>0;i--) 11 | { 12 | for(int z=2;z<=i/2;z++) 13 | { 14 | if(i%z==0){ 15 | flag=0; 16 | break; 17 | } 18 | else 19 | flag=1; 20 | 21 | } 22 | if(flag==1) 23 | return i; 24 | } 25 | } 26 | } 27 | int main() 28 | { 29 | int n,m; 30 | cin>>n>>m; 31 | int t=prime(n); 32 | int h=prime(m); 33 | cout< 2 | using namespace std; 3 | int main(){ 4 | 5 | int a[3]; 6 | while(cin>>a[0]>>a[1]>>a[2]){ 7 | 8 | bool x=false; 9 | sort(a,a+3); 10 | int check=a[0]; 11 | if(pow(a[2],2)==pow(a[1],2)+pow(a[0],2)){ 12 | while(check>1) 13 | { 14 | if((a[0]%check==0)&&(a[1]%check==0)&&(a[2]%check==0)) 15 | x=true; 16 | check--; 17 | } 18 | if(x==false) 19 | cout<<"tripla pitagorica primitiva\n"; 20 | else 21 | cout<<"tripla pitagorica\n"; 22 | } 23 | else 24 | cout<<"tripla\n"; 25 | 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /1050.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int number; 8 | cin>>number; 9 | if(number==61) 10 | cout<<"Brasilia\n"; 11 | else if(number==71) 12 | cout<<"Salvador\n"; 13 | else if(number==11) 14 | cout<<"Sao Paulo\n"; 15 | else if(number==21) 16 | cout<<"Rio de Janeiro\n"; 17 | else if(number==32) 18 | cout<<"Juiz de Fora\n"; 19 | else if(number==19) 20 | cout<<"Campinas\n"; 21 | else if(number==27) 22 | cout<<"Vitoria\n"; 23 | else if(number==31) 24 | cout<<"Belo Horizonte\n"; 25 | else 26 | cout<<"DDD nao cadastrado\n"; 27 | 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /1042.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int a[3],x,y,z; 7 | for(int i=0;i<3;i++) 8 | { 9 | cin>>a[i]; 10 | } 11 | x=a[0]; 12 | y=a[1]; 13 | z=a[2]; 14 | for(int i=0;i<2;i++) 15 | { 16 | for(int j=0;j<2;j++){ 17 | if(a[j+1] 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | long long int sum1=1,sum2=1,sum=0; 9 | int a,b; 10 | 11 | while((scanf("%lld%lld",&a,&b))!=EOF) 12 | { 13 | if(a==0||a==1) 14 | sum1=1; 15 | else 16 | { 17 | for(int i=2;i<=a;i++) 18 | sum1=sum1*i; 19 | } 20 | if(b==0||b==1) 21 | sum2=1; 22 | else 23 | { 24 | for(int i=2;i<=b;i++) 25 | sum2=sum2*i; 26 | } 27 | sum=sum1+sum2; 28 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | while(cin>>n) 7 | { 8 | bool x=false; 9 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | string str[4]; 8 | int t; 9 | int m,n; 10 | cin>>t; 11 | while(t-->0) 12 | { 13 | cin>>str[0]>>str[1]>>str[2]>>str[3]; 14 | cin>>m>>n; 15 | m=m+n; 16 | if(m%2==0) 17 | { 18 | if(str[1]=="PAR") 19 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a,b,t,sum; 8 | cin>>t; 9 | while(t){ 10 | cin>>a>>b; 11 | sum=0; 12 | if(a>b) 13 | { 14 | for(int i=a-1;i>b;i--) 15 | { 16 | if(i%2!=0) 17 | { 18 | sum=sum+i; 19 | } 20 | } 21 | } 22 | else if(a 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | #define ll long long 18 | #define MAX 999999999999999999 19 | #define MIN 0 20 | #define PI acos(-1) 21 | #define E 2.718281828459 22 | #define ii pair 23 | 24 | int main(int argc, char** argv) { 25 | //freopen("c.txt","w",stdout); 26 | int A,B; 27 | while(cin>>A>>B) 28 | { 29 | if(A==B)cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | /** 8 | * Escreva a sua solução aqui 9 | * Code your solution here 10 | * Escriba su solución aquí 11 | */ 12 | int t; 13 | cin>>t; 14 | double sum=0.0; 15 | while(t-->0) 16 | { 17 | int n,m; 18 | cin>>n>>m; 19 | if(n==1001) 20 | sum=sum+(m*1.50); 21 | if(n==1002) 22 | sum=sum+(m*2.50); 23 | if(n==1003) 24 | sum=sum+(m*3.50); 25 | if(n==1004) 26 | sum=sum+(m*4.50); 27 | if(n==1005) 28 | sum=sum+(m*5.50); 29 | } 30 | printf("%.2lf\n",sum); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /2551.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int t; 5 | while(cin>>t){ 6 | 7 | float A[t]; 8 | for(int i=1;i<=t;i++){ 9 | float a,b; 10 | cin>>a>>b; 11 | float m=b/a; 12 | A[i-1]=m; 13 | } 14 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | #define g 9.81 26 | 27 | int main(int argc, char** argv) { 28 | int D; 29 | cin>>D; 30 | if(D >1400) 31 | cout<<3<800)cout<<2< 2 | using namespace std; 3 | int main() 4 | { 5 | string a,b,c; 6 | cin>>a>>b>>c; 7 | if(a[0]=='v') 8 | { 9 | if(b[0]=='a'){ 10 | if(c[0]=='c')cout<<"aguia\n"; 11 | else cout<<"pomba\n"; 12 | } 13 | else{ 14 | if(c[0]=='o')cout<<"homem\n"; 15 | else cout<<"vaca\n"; 16 | } 17 | } 18 | else{ 19 | if(b[0]=='i') 20 | { 21 | if(c.length()==10)cout<<"pulga\n"; 22 | else cout<<"lagarta\n"; 23 | } 24 | else{ 25 | if(c[0]=='h')cout<<"sanguessuga\n"; 26 | else cout<<"minhoca\n"; 27 | } 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /1252.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int m; 4 | bool comp (int a, int b){ 5 | if (b%m == a%m) 6 | if(abs(a)%2 ==abs(b)%2){ 7 | if (a%2 != 0){ 8 | return a > b; 9 | }else{ 10 | return b > a; 11 | } 12 | } 13 | return abs(a)%2 > abs(b)%2; 14 | } 15 | return a%m < b%m; 16 | } 17 | int main() 18 | { 19 | int n; 20 | 21 | while(cin>>n>>m&&n&&m){ 22 | int a[n]; 23 | for(int i=0;i>a[i]; 26 | } 27 | sort(a,a+n,comp); 28 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | string str; 28 | getline(cin,str); 29 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace std; 20 | 21 | typedef long long ll; 22 | 23 | 24 | #define PI acos(-1) 25 | #define E 2.718281828459 26 | #define g 9.81 27 | 28 | 29 | int main(int argc, char** argv) { 30 | 31 | int n; 32 | for(int i=1;i<=4;i++) 33 | { 34 | cin>>n; 35 | if(n==1)cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | char a,b,c; 28 | cin>>a>>b>>c; 29 | printf("A = %c, B = %c, C = %c\n",a,b,c); 30 | printf("A = %c, B = %c, C = %c\n",b,c,a); 31 | printf("A = %c, B = %c, C = %c\n",c,a,b); 32 | } 33 | -------------------------------------------------------------------------------- /1310.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | while(cin>>n) 7 | { 8 | int cost; 9 | cin>>cost; 10 | vector a(n); 11 | for(int i=0;i>a[i]; 14 | } 15 | int maxSumSoFar=0; 16 | 17 | int maxISoFar=0; 18 | 19 | int maxJSoFar=-1; 20 | 21 | for(int i=0; imaxSumSoFar){ 31 | 32 | maxSumSoFar=sum; 33 | 34 | maxISoFar=i; 35 | 36 | maxJSoFar=j; 37 | 38 | } 39 | 40 | } 41 | 42 | } 43 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int test_case; 6 | cin>>test_case; 7 | while(test_case--) 8 | { 9 | char c; 10 | int a,b; 11 | cin>>a>>c>>b; 12 | int A,B; 13 | cin>>B>>c>>A; 14 | if(a+A>b+B) 15 | { 16 | cout<<"Time 1\n"; 17 | } 18 | else if(a+Ab) 26 | cout<<"Time 1\n"; 27 | else{ 28 | cout<<"Penaltis\n"; 29 | } 30 | } 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /2763.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | string str; 28 | getline(cin,str); 29 | for(int i=0;i='0'&&str[i]<='9')cout< 2 | using namespace std; 3 | int main() 4 | { 5 | char c; 6 | string temp; 7 | set uri; 8 | while(cin.get(c)) 9 | { 10 | if((c>=65&&c<=90)||(c>=97&&c<=122)) 11 | { 12 | temp+=tolower(c); 13 | } 14 | else 15 | { 16 | uri.insert(temp); 17 | temp.clear(); 18 | } 19 | } 20 | if(!temp.empty()) 21 | { 22 | uri.insert(temp); 23 | temp.clear(); 24 | } 25 | int s=uri.size(); 26 | for(set::iterator i=uri.begin();i!=uri.end();i++) 27 | { 28 | if(i==uri.begin())i++; 29 | if(*i!="\n") 30 | cout<<*i< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | int I=1; 17 | typedef long long ll; 18 | 19 | int main() 20 | { 21 | //freopen("c.txt","w",stdout); 22 | int n; 23 | while(cin>>n) 24 | { 25 | int div=0; 26 | int count=0; 27 | int mod=0; 28 | while(true) 29 | { 30 | mod=(mod*10)+1; 31 | count++; 32 | mod=mod%n; 33 | if(!mod)break; 34 | } 35 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t,small,l,a,b,r,large; 8 | cin>>t; 9 | cin.ignore(); 10 | while(t-->0) 11 | { 12 | cin>>a>>b; 13 | if(a<=b){ 14 | small=a; 15 | large=b; 16 | } 17 | else{ 18 | small=b; 19 | large=a; 20 | } 21 | while(true) 22 | { 23 | if(large%small==0){ 24 | l=small; 25 | break; 26 | } 27 | else{ 28 | int temp=large; 29 | large=small; 30 | small=temp%small; 31 | 32 | } 33 | } 34 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c; 6 | cin>>a>>b>>c; 7 | if(b>a&&c<=b) 8 | printf(":(\n"); 9 | else if(b>a&&c>b&&(c-b)<(b-a)) 10 | printf(":(\n"); 11 | else if(b>a&&c>b&&(c-b)>=(b-a)) 12 | printf(":)\n"); 13 | else if(b=(a-b)) 16 | printf(":(\n"); 17 | else if((a==b)&&c>b) 18 | printf(":)\n"); 19 | else if((a==b)&&c=b) 22 | printf(":)\n"); 23 | else 24 | printf(":(\n"); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /1091.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | //freopen("c.txt","w",stdout); 6 | int t; 7 | while(cin>>t&&t) 8 | { 9 | int x,y; 10 | cin>>x>>y; 11 | int a,b; 12 | while(t--) 13 | { 14 | cin>>a>>b; 15 | if(x==a||y==b)printf("divisa\n"); 16 | else 17 | { 18 | if(a>x) 19 | { 20 | if(b>y)printf("NE\n"); 21 | else printf("SE\n"); 22 | } 23 | else{ 24 | if(b>y)printf("NO\n"); 25 | else printf("SO\n"); 26 | } 27 | } 28 | } 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /2091.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | while(cin>>n&&n) 7 | { 8 | long long a[n]; 9 | for(int i=0;i>a[i]; 11 | sort(a,a+n); 12 | bool find=false; 13 | int index=0; 14 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | #define ll long long 17 | #define input scanf 18 | #define output printf 19 | #define Loop while 20 | #define echo cout 21 | #define ret return 22 | #define MAX 999999999999999999 23 | #define MIN 0 24 | int main(int argc, char** argv) { 25 | 26 | //freopen("c.txt","w",stdout); 27 | string str; 28 | int n; 29 | cin>>n; 30 | int a,b; 31 | cin>>a>>b; 32 | if(a+b<=n) 33 | printf("Farei hoje!\n"); 34 | else 35 | printf("Deixa para amanha!\n"); 36 | ret 0; 37 | } 38 | -------------------------------------------------------------------------------- /1957.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | long long str,mod; 6 | cin>>str; 7 | string p; 8 | while(str>0) 9 | { 10 | mod = str % 16; 11 | str /= 16; 12 | if(mod<=9){ 13 | char c=mod+'0'; 14 | p=p+c; 15 | } 16 | else if(mod==10) 17 | p=p+'A'; 18 | else if(mod==11) 19 | p=p+'B'; 20 | else if(mod==12) 21 | p=p+'C'; 22 | else if(mod==13) 23 | p=p+'D'; 24 | else if(mod==14) 25 | p=p+'E'; 26 | else if(mod==15) 27 | p=p+'F'; 28 | } 29 | for(int i=p.length()-1;i>=0;i--) 30 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | #define g 9.81 26 | 27 | int main(int argc, char** argv) { 28 | 29 | int L,C; 30 | cin>>L>>C; 31 | int sum=L*C; 32 | sum+=(L-1)*(C-1); 33 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a[5]; 8 | int even=0,odd=0,positive=0,negative=0; 9 | 10 | for(int i=0;i<5;i++) 11 | { 12 | cin>>a[i]; 13 | if(a[i]%2==0) 14 | { 15 | even++; 16 | } 17 | if(a[i]%2!=0) 18 | { 19 | odd++; 20 | } 21 | if(a[i]>0) 22 | { 23 | positive++; 24 | } 25 | if(a[i]<0) 26 | { 27 | negative++; 28 | } 29 | } 30 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | //freopen("c.txt","w",stdout); 6 | unsigned long long int num; 7 | while(cin>>num) 8 | { 9 | if(num==0) 10 | { 11 | cout<<0<=0;j--) 27 | { 28 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | int main() 5 | { 6 | ios::sync_with_stdio(false); 7 | cin.tie(0); 8 | int t; 9 | cin>>t; 10 | string f; 11 | getline(cin,f); 12 | while(t--) 13 | { 14 | 15 | string str,s; 16 | getline(cin,str); 17 | getline(cin,s); 18 | for(int i=1,j=0,k=0;i<=str.length();i++) 19 | { 20 | if(i%2==0) 21 | { 22 | cout<k+1)cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | while(cin>>n) 7 | { 8 | int x=n/2+1; 9 | for(int i=1;i<=x;i++) 10 | { 11 | //printing space 12 | for(int j=i;j<=n/2;j++) 13 | cout<<" "; 14 | int p=2*i-1; 15 | for(int s=1;s<=p;s++) 16 | cout<<"*"; 17 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | vector a(3); 6 | cin>>a[0]>>a[1]>>a[2]; 7 | sort(a.begin(),a.end()); 8 | if(a[0]+a[1]<=a[2]) 9 | printf("NAO FORMA TRIANGULO\n"); 10 | else{ 11 | if(a[2]*a[2]==((a[1]*a[1])+(a[0]*a[0]))) 12 | printf("TRIANGULO RETANGULO\n"); 13 | if(a[2]*a[2]>((a[1]*a[1])+(a[0]*a[0]))) 14 | printf("TRIANGULO OBTUSANGULO\n"); 15 | if(a[2]*a[2]<((a[1]*a[1])+(a[0]*a[0]))) 16 | printf("TRIANGULO ACUTANGULO\n"); 17 | if(a[0]==a[1]&&a[1]==a[2]) 18 | printf("TRIANGULO EQUILATERO\n"); 19 | if((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2])) 20 | printf("TRIANGULO ISOSCELES\n"); 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /1249.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | char str[1000]; 8 | while(gets(str)!= NULL) 9 | { 10 | for(int i=0;i='A'&&str[i]<='Z') 13 | { 14 | if(str[i]<'N') 15 | str[i]=str[i]+13; 16 | else 17 | str[i]=str[i]+13-26; 18 | } 19 | if(str[i]>='a'&&str[i]<='z') 20 | { 21 | if(str[i]<'n') 22 | str[i]=str[i]+13; 23 | else 24 | str[i]=str[i]+13-26; 25 | } 26 | } 27 | cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | char str[1000][1000]; 7 | int t,i=0; 8 | cin>>t; 9 | cin.ignore(); 10 | while(t-->0) 11 | { 12 | cin>>str[i]; 13 | i++; 14 | } 15 | for(int j=0;j 2 | using namespace std; 3 | int main(){ 4 | int t; 5 | while(cin>>t) 6 | { 7 | vector > x; 8 | string h;int j; 9 | while(t--) 10 | { 11 | cin>>h>>j; 12 | x.push_back(make_pair(h,j)); 13 | } 14 | for(int i=0;ix[ptr+1].second) 20 | swap(x[ptr],x[ptr+1]); 21 | ptr++; 22 | } 23 | } 24 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 17 | using namespace std; 18 | 19 | typedef long long ll; 20 | 21 | int main(int argc, char** argv){ 22 | string str; 23 | while(getline(cin,str)) 24 | { 25 | if(str=="esquerda")cout<<"ingles\n"; 26 | 27 | else if(str=="direita")cout<<"frances\n"; 28 | 29 | else if(str=="nenhuma")cout<<"portugues\n"; 30 | else cout<<"caiu\n"; 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /2044.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n,p; 6 | while(cin>>n) 7 | { 8 | if(n==-1)break; 9 | int sum=0; 10 | int _100=0; 11 | for(int i=0;i>p; 14 | sum+=p; 15 | if(sum%100==0)_100++; 16 | } 17 | cout<<_100< 21 | using namespace std; 22 | int main() 23 | { 24 | int n,p; 25 | while(cin>>n) 26 | { 27 | if(n==-1)break; 28 | int sum=0; 29 | int _100=0; 30 | for(int i=0;i>p; 33 | sum+=p; 34 | if(sum%100==0)_100++; 35 | } 36 | cout<<_100< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int number; 8 | cin>>number; 9 | if(number==1) 10 | cout<<"January\n"; 11 | else if(number==2) 12 | cout<<"February\n"; 13 | else if(number==3) 14 | cout<<"March\n"; 15 | else if(number==4) 16 | cout<<"April\n"; 17 | else if(number==5) 18 | cout<<"May\n"; 19 | else if(number==6) 20 | cout<<"June\n"; 21 | else if(number==7) 22 | cout<<"July\n"; 23 | else if(number==8) 24 | cout<<"August\n"; 25 | else if(number==9) 26 | cout<<"September\n"; 27 | else if(number==10) 28 | cout<<"October\n"; 29 | else if(number==11) 30 | cout<<"November\n"; 31 | else if(number==12) 32 | cout<<"December\n"; 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /1219.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define pi 3.1415926535897 4 | int main() 5 | { 6 | vector a(3); 7 | while(cin>>a[0]>>a[1]>>a[2]) 8 | { 9 | sort(a.begin(),a.end()); 10 | double s=(a[0]+a[1]+a[2])/2; 11 | double triangleArea=sqrt(s*(s-a[0])*(s-a[1])*(s-a[2])); 12 | double circleRadius=(a[0]*a[1]*a[2])/(4*triangleArea); 13 | double circleArea=pi*pow(circleRadius,2); 14 | double innerCirclerRadius=triangleArea/s; 15 | double innerCircleArea=pi*pow(innerCirclerRadius,2); 16 | double triangleReducedArea=triangleArea-innerCircleArea; 17 | circleArea-=triangleArea; 18 | printf("%.4lf %.4lf %.4lf\n",circleArea,triangleReducedArea,innerCircleArea); 19 | 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /1256.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin>>n; 9 | bool x=false; 10 | while(n--) 11 | { 12 | if(x) 13 | { 14 | cout<>a>>b; 20 | int c[b],i=0; 21 | for(int j=0;j>c[j]; 23 | for(i=0;i "; 26 | for(int j=0;j"; 28 | if(c[j]%a==i) 29 | cout< "; 30 | //if(i+1==a) 31 | //cout<<" \\n"; 32 | } 33 | cout<<"\\\n"; 34 | } 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /2356.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | string x,y; 6 | while(cin>>x>>y){ 7 | bool X=false; 8 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | string x[50]; 8 | int l=0; 9 | int t,flag=0; 10 | while(1) 11 | { 12 | cin>>t; 13 | if(t==0) 14 | break; 15 | if(flag==1) 16 | cout<0) 19 | //{ 20 | for(int j=0;j>x[j]; 22 | if(x[j].length()>l) 23 | l=x[j].length(); 24 | } 25 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | #define g 9.81 26 | 27 | int main(int argc, char** argv) { 28 | int i,j; 29 | cin>>i>>j; 30 | if(i%2==0) 31 | { 32 | if(j%2==0)cout<<1< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | int I=1; 17 | typedef long long ll; 18 | 19 | int main() 20 | { 21 | //freopen("c.txt","w",stdout); 22 | ios::sync_with_stdio(0); 23 | cin.tie(0); 24 | int t; 25 | string str; 26 | cin>>t; 27 | while(t--) 28 | { 29 | cin>>str; 30 | for(int i=str.length()-1;i>=0;i--) 31 | { 32 | if(str[i]>=97&&str[i]<=122) 33 | { 34 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 17 | using namespace std; 18 | 19 | typedef long long ll; 20 | 21 | int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } 22 | int main(int argc, char** argv) { 23 | //freopen("c.txt","w",stdout); 24 | int l,c,x,y; 25 | cin>>l>>c>>x>>y; 26 | x++; 27 | y++; 28 | ll lll=x-1; 29 | lll=lll*c; 30 | lll+=y; 31 | if(lll%2==0)cout<<"Esquerda\n"; 32 | else cout<<"Direita\n"; 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /2674.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | bool isPrime(int n) 4 | { 5 | if(n==0||n==1)return false; 6 | if(n==2) return true; 7 | if(n%2==0)return false; 8 | for(int i=3;i<=sqrt(n);i+=2) 9 | { 10 | if(n%i==0)return false; 11 | } 12 | return true; 13 | } 14 | bool isSuperPrime(int n) 15 | { 16 | while(n>=10) 17 | { 18 | int s=n%10; 19 | n/=10; 20 | if(!isPrime(s)) 21 | return false; 22 | } 23 | if(n==2||n==3||n==7||n==5)return true; 24 | else return false; 25 | } 26 | int main() 27 | { 28 | int n; 29 | while(cin>>n) 30 | { 31 | if(!isPrime(n))cout<<"Nada\n"; 32 | else 33 | { 34 | if(isSuperPrime(n))cout<<"Super\n"; 35 | else cout<<"Primo\n"; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /2756.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | printf(" A\n"); 28 | printf(" B B\n"); 29 | printf(" C C\n"); 30 | printf(" D D\n"); 31 | printf(" E E\n"); 32 | printf(" D D\n"); 33 | printf(" C C\n"); 34 | printf(" B B\n"); 35 | printf(" A\n"); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /1237.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | string str1,str2; 6 | getline(cin,str1); 7 | while(getline(cin,str2)){ 8 | int len=0,len2=0; 9 | for(int i=0;ilen){ 25 | len=len2; 26 | } 27 | } 28 | 29 | 30 | } 31 | } 32 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | double x,y; 8 | int c=1; 9 | while(c==1) 10 | { 11 | while(1) 12 | { 13 | cin>>x; 14 | if(x>=0&&x<=10) 15 | break; 16 | cout<<"nota invalida\n"; 17 | } 18 | while(1) 19 | { 20 | cin>>y; 21 | if(y>=0&&y<=10) 22 | break; 23 | cout<<"nota invalida\n"; 24 | } 25 | x=x+y; 26 | x=x/2.00; 27 | printf("media = %.2lf\n",x); 28 | while(1) 29 | { 30 | cin>>c; 31 | if(c>=1&&c<=2) 32 | break; 33 | cout<<"novo calculo (1-sim 2-nao)\n"; 34 | } 35 | cout<<"novo calculo (1-sim 2-nao)\n"; 36 | } 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /1260.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | //freopen("map.txt","w",stdout); 6 | int t,I=1; 7 | scanf("%d",&t); 8 | cin.ignore(); 9 | cin.ignore(); 10 | string str; 11 | while(t--) 12 | { 13 | int n=0; 14 | if(I!=1) 15 | cout< a; 17 | map::iterator i; 18 | while(getline(cin,str)) 19 | { 20 | if(str.size()==0)break; 21 | a[str]++; 22 | n++; 23 | } 24 | for(i=a.begin();i!=a.end();i++) 25 | { 26 | string s=i->first; 27 | int x=i->second; 28 | double per=x*100.0/(double)n; 29 | printf("%s %.4lf\n", s.c_str(), per); 30 | } 31 | I++; 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /2059.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | /** 8 | * Escreva a sua solução aqui 9 | * Code your solution here 10 | * Escriba su solución aquí 11 | */ 12 | int a,b,c,d,e; 13 | cin>>a>>b>>c>>d>>e; 14 | if(d) 15 | { 16 | if(e) 17 | cout<<"Jogador 2 ganha!\n"; 18 | else 19 | cout<<"Jogador 1 ganha!\n"; 20 | } 21 | else 22 | { 23 | if(e) 24 | cout<<"Jogador 1 ganha!\n"; 25 | else{ 26 | int sum=c+b; 27 | int r; 28 | if(sum%2) 29 | r=0; 30 | else 31 | r=1; 32 | if(r==a) 33 | cout<<"Jogador 1 ganha!\n"; 34 | else 35 | cout<<"Jogador 2 ganha!\n"; 36 | 37 | } 38 | } 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /2600.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | int a[6]; 10 | bool dice=true; 11 | bool Find[7]; 12 | for(int i=0;i<=6;i++) 13 | Find[i]=false; 14 | for(int i=0;i<6;i++) 15 | { 16 | cin>>a[i]; 17 | if(a[i]<1||a[i]>6) 18 | dice=false; 19 | else{ 20 | if(!Find[a[i]]) 21 | Find[a[i]]=true; 22 | else dice=false; 23 | } 24 | 25 | } 26 | if(dice) 27 | { 28 | if((a[0]+a[5]==7)&&(a[1]+a[3]==7)&&(a[2]+a[4]==7)) 29 | cout<<"SIM\n"; 30 | else cout<<"NAO\n"; 31 | } 32 | else cout<<"NAO\n"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /1239.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | char x[1000]; 7 | string str; 8 | while(gets(x) != NULL ) { 9 | str=x; 10 | int o=0,e=0; 11 | for(int i=0;i"; 18 | else 19 | cout<<""; 20 | } 21 | else if(str[i]=='*') 22 | { 23 | e++; 24 | if(e%2==0) 25 | cout<<""; 26 | else 27 | cout<<""; 28 | } 29 | else 30 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string x; 6 | int t; 7 | cin>>t; 8 | while(t!=0) 9 | { 10 | string x; 11 | cin>>x; 12 | int n=1; 13 | for(int i=0;i4) 19 | n=1; 20 | } 21 | if(x[i]=='E') 22 | { 23 | n--; 24 | if(n==0) 25 | n=4; 26 | 27 | } 28 | } 29 | if(n==1) 30 | cout<<"N\n"; 31 | if(n==2) 32 | cout<<"L\n"; 33 | if(n==3) 34 | cout<<"S\n"; 35 | if(n==4) 36 | cout<<"O\n"; 37 | cin>>t; 38 | } 39 | return 0; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /1160.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin >> t; 7 | while(t-->0) 8 | { 9 | int small, big; 10 | double rate1 , rate2; 11 | double city1=0,city2=0; 12 | int year=1; 13 | cin >> small >> big; 14 | cin >> rate1 >> rate2; 15 | while(true) 16 | { 17 | city1=(rate1*small)/100; 18 | city2=(rate2*big)/100; 19 | small=small+city1; 20 | big=big+city2; 21 | if(small>big){ 22 | cout<100){ 28 | cout<<"Mais de 1 seculo.\n"; 29 | break; 30 | } 31 | } 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /1129.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | int main() 6 | { 7 | int t; 8 | cin>>t; 9 | char b[5]; 10 | b[0]='A'; 11 | b[1]='B'; 12 | b[2]='C'; 13 | b[3]='D'; 14 | b[4]='E'; 15 | while(t!=0) 16 | { 17 | while(t--) 18 | { 19 | int a[5]; 20 | int flag=0; 21 | int low=0; 22 | for(int i=0;i<5;i++) 23 | { 24 | cin>>a[i]; 25 | if(a[i]<=127) 26 | { 27 | flag++; 28 | if(flag==1) 29 | low=i; 30 | } 31 | } 32 | if(flag==1) 33 | cout<>t; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /1068.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | string X; 6 | while(cin>>X){ 7 | //int forward=0,backword=0; 8 | int forward=0; 9 | bool x=false; 10 | for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | float sum=0.00,dif=0.00,sum1=0.00,sum2=0.00; 8 | float dif2=0.00,dif1=0.00; 9 | while(t--) 10 | { 11 | string str; 12 | cin>>str; 13 | int x,y,z; 14 | cin>>x>>y>>z; 15 | sum=sum+x; 16 | sum1=sum1+y; 17 | sum2=sum2+z; 18 | int A,B,C; 19 | cin>>A>>B>>C; 20 | dif=dif+A; 21 | dif1=dif1+B; 22 | dif2=dif2+C; 23 | } 24 | float p,q,r; 25 | p=(dif*100.00)/sum; 26 | q=(dif1*100.00)/sum1; 27 | r=(dif2*100.00)/sum2; 28 | printf("Pontos de Saque: %.2f",p); 29 | cout<<" %.\n"; 30 | printf("Pontos de Bloqueio: %.2f",q); 31 | cout<<" %.\n"; 32 | printf("Pontos de Ataque: %.2f",r); 33 | cout<<" %.\n"; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /2582 .cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a; 6 | cin>>a; 7 | while(a--){ 8 | int x,y; 9 | cin>>x>>y; 10 | x=x+y; 11 | if(x==0) 12 | cout<<"PROXYCITY\n"; 13 | else if(x==1) 14 | cout<<"P.Y.N.G.\n"; 15 | else if(x==2) 16 | cout<<"DNSUEY!\n"; 17 | else if(x==3) 18 | cout<<"SERVERS\n"; 19 | else if(x==4) 20 | cout<<"HOST!\n"; 21 | else if(x==5) 22 | cout<<"CRIPTONIZE\n"; 23 | else if(x==6) 24 | cout<<"OFFLINE DAY\n"; 25 | else if(x==7) 26 | cout<<"SALT\n"; 27 | else if(x==8) 28 | cout<<"ANSWER!\n"; 29 | else if(x==9) 30 | cout<<"RAR?\n"; 31 | else if(x==10) 32 | cout<<"WIFI ANTENNAS\n"; 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /1051.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | double money,tax=0,x; 6 | cin>>money; 7 | if(money<=2000.00) 8 | { 9 | cout<<"Isento\n"; 10 | } 11 | else 12 | { 13 | x=money-2000.00; 14 | while(1) 15 | { 16 | if(x<=1000.00) 17 | { 18 | tax=tax+((8.00*x)/100); 19 | break; 20 | } 21 | if(x>1000.00&&x<=2500.00) 22 | { 23 | x=x-1000.00; 24 | tax=tax+((18.00*x)/100); 25 | x=1000.00; 26 | 27 | } 28 | if(x>2500.00) 29 | { 30 | x=x-2500.00; 31 | tax=tax+((28.00*x)/100); 32 | x=2500.00; 33 | } 34 | } 35 | printf("R$ %.2lf\n",tax); 36 | } 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /2568.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 17 | using namespace std; 18 | 19 | typedef long long ll; 20 | 21 | #define PI acos(-1) 22 | #define e 2.718281828459 23 | 24 | int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } 25 | int main(int argc, char** argv) { 26 | //freopen("c.txt","w",stdout); 27 | int D,I,X,F; 28 | cin>>D>>I>>X>>F; 29 | int sum=I; 30 | for(int i=D+1;i<=D+F;i++) 31 | { 32 | if(i%2!=0) 33 | sum-=X; 34 | else sum+=X; 35 | } 36 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string str,x; 6 | char c; 7 | while(1) 8 | { 9 | cin>>c>>str; 10 | int flag=1; 11 | if(c=='0'&&str=="0") 12 | break; 13 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 17 | using namespace std; 18 | 19 | typedef long long ll; 20 | 21 | #define PI acos(-1) 22 | #define e 2.718281828459 23 | 24 | int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } 25 | int main(int argc, char** argv) { 26 | //freopen("c.txt","w",stdout); 27 | int p1,c1,p2,c2; 28 | cin>>p1>>c1>>p2>>c2; 29 | if((p1*c1)==(p2*c2)) 30 | { 31 | cout<<0<(p2*c2))cout<<-1< 2 | using namespace std; 3 | int main() 4 | { 5 | int n,d; 6 | while(cin>>n>>d) 7 | { 8 | if(n==0&&d==0) 9 | break; 10 | int a[d][n]; 11 | for(int i=0;i>a[i][j]; 15 | } 16 | int sum=0; 17 | bool x=false; 18 | int I=0,J=0; 19 | while(I!=d&&J!=n) 20 | { 21 | for(int i=0;i 2 | #include 3 | 4 | #include 5 | 6 | int main() 7 | 8 | { 9 | 10 | char str[1000],str1[1000]; 11 | 12 | int i,k,j,n,m,l,T; 13 | 14 | scanf("%d",&T); 15 | 16 | getchar(); 17 | 18 | while(T--) { 19 | 20 | gets(str); 21 | 22 | k = strlen(str); 23 | 24 | for(i=0;i='A' && str[i]<='Z') || (str[i]>='a'&& str[i]<='z')) 29 | 30 | str[i] = str[i] + 3; 31 | 32 | } 33 | 34 | n=0; 35 | 36 | for(j=k-1;j>=0;j--) 37 | 38 | { 39 | 40 | str1[n] = str[j]; 41 | 42 | n++; 43 | 44 | } 45 | 46 | str1[n] = '\0'; 47 | 48 | l = k/2; 49 | 50 | for(i=l;i 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int a,b; 7 | cin>>a>>b; 8 | a=a+b; 9 | while(a!=0||b!=0) 10 | { 11 | char x[100],i=0; 12 | while(true){ 13 | if(a>=100){ 14 | int f=a%100; 15 | if(f>9){ 16 | f=f%10; 17 | } 18 | x[i]=f+48; 19 | a=a/10; 20 | i++; 21 | } 22 | if(a>=10&&a<100){ 23 | int f=a%10; 24 | x[i]=f+48; 25 | a=a/10; 26 | i++; 27 | } 28 | if(a<10){ 29 | x[i]=a+48; 30 | break; 31 | } 32 | } 33 | for(int u=i;u>=0;u--){ 34 | if(x[u]!='0') 35 | cout<>a>>b; 39 | a=a+b; 40 | 41 | } 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /1944.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | typedef long long ll; 6 | #define INF 99999999 7 | int main() 8 | { 9 | int t; 10 | cin>>t; 11 | char a,b,c,d; 12 | char A,B,C,D; 13 | stack q; 14 | int count=0; 15 | while(t--) 16 | { 17 | if(q.empty()) 18 | { 19 | q.push('F');q.push('A');q.push('C');q.push('E'); 20 | } 21 | cin>>a>>b>>c>>d; 22 | D=q.top();q.pop(); 23 | C=q.top();q.pop(); 24 | B=q.top();q.pop(); 25 | A=q.top();q.pop(); 26 | //cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int a1[5],a2[5]; 7 | int count1=0,count2=0,num; 8 | for(int i=0;i<15;i++) 9 | { 10 | cin>>num; 11 | if(num%2==0) 12 | { 13 | a1[count1]=num; 14 | count1++; 15 | } 16 | if(num%2!=0) 17 | { 18 | a2[count2]=num; 19 | count2++; 20 | } 21 | if(count2==5||i==14) 22 | { 23 | for(int o=0;o 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define input scanf 17 | #define output printf 18 | #define Loop while 19 | #define echo cout 20 | #define ret return 21 | #define MAX 999999999999999999 22 | 23 | ll a[5001]; 24 | 25 | void sieve() 26 | { 27 | a[0]=0; 28 | a[1]=1; 29 | for(int i=2;i<=5000;i++) 30 | { 31 | a[i]=i*i; 32 | } 33 | ret; 34 | } 35 | int main(int argc, char** argv) { 36 | 37 | sieve(); 38 | int n; 39 | 40 | Loop((input("%d",&n)==1)&&n) 41 | { 42 | int x=sqrt(n); 43 | int i=1; 44 | Loop(in)break; 47 | output("%lld ",a[i++]); 48 | } 49 | output("%lld\n",a[x]); 50 | } 51 | ret 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /1520.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | 12 | int main(int argc, char** argv) { 13 | int n,m; 14 | int x,y; 15 | while((scanf("%d",&n)==1)) 16 | { 17 | vector a; 18 | vector num(101); 19 | fill(a.begin(),a.end(),0); 20 | while(n--) 21 | { 22 | scanf("%d%d",&x,&y); 23 | for(int i=x;i<=y;i++) 24 | { 25 | a.push_back(i); 26 | num[i]++; 27 | } 28 | } 29 | sort(a.begin(),a.end()); 30 | scanf("%d",&x); 31 | if(num[x]==0) 32 | printf("%d not found\n",x); 33 | else 34 | { 35 | int in; 36 | for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | string str; 6 | int count=1,sum=0; 7 | while(count<=3) 8 | { 9 | getline(cin,str); 10 | if(str[0]=='c') 11 | { 12 | cout< 2 | using namespace std; 3 | int a[1001]; 4 | void frequency() 5 | { 6 | a[0]=3; 7 | a[1]=1; 8 | for(int i=2;i<=1000;i++) 9 | { 10 | int count=2; 11 | for(int j=2;j<=(i/2);j++) 12 | { 13 | if(i%j==0)count++; 14 | } 15 | a[i]=count; 16 | } 17 | /*for(int i=0;i<=1000;i++) 18 | { 19 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int a,b,sum=0,big,small; 8 | while(1) 9 | { 10 | cin>>a>>b; 11 | sum=0; 12 | if(a<=0||b<=0) 13 | break; 14 | else 15 | { 16 | if(a>b){ 17 | big=a; 18 | small=b; 19 | for(int i=small;i<=big;i++) 20 | { 21 | cout<=13&&e<14) 18 | cout<<"E 13\n"; 19 | else if(e>=14&&e<40.00) 20 | cout<<"Bora, hora do show! BIIR!\n"; 21 | else if(e>=40&&e<=60.00) 22 | cout<<"Ta saindo da jaula o monstro!\n"; 23 | else 24 | cout<<"AQUI E BODYBUILDER!!\n"; 25 | 26 | ave+=e; 27 | count+=1; 28 | cin>>a>>b>>c; 29 | } 30 | ave=ave/count; 31 | if(ave>40) 32 | { 33 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | string str; 28 | str="AMO FAZER EXERCICIO NO URI"; 29 | printf("<% s>\n",str.c_str()); 30 | printf("<% 30s>\n",str.c_str()); 31 | printf("<% .20s>\n",str.c_str()); 32 | printf("<% -20s>\n",str.c_str()); 33 | printf("<% -30s>\n",str.c_str()); 34 | printf("<% .30s>\n",str.c_str()); 35 | printf("<% 30.20s>\n",str.c_str()); 36 | printf("<% -30.20s>\n",str.c_str()); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /1162.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int bubble_up(int a[],int size); 4 | int main() 5 | { 6 | int t; 7 | cin>>t; 8 | while(t--){ 9 | int n; 10 | cin>>n; 11 | int a[n]; 12 | for(int i=0;i>a[i]; 15 | } 16 | int size=bubble_up(a,n); 17 | printf("Optimal train swapping takes %d swaps.\n",size); 18 | } 19 | return 0; 20 | } 21 | int bubble_up(int a[],int size) 22 | { 23 | int count=0; 24 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | printf("---------------------------------------\n"); 28 | printf("| Roberto |\n"); 29 | printf("| |\n"); 30 | printf("| 5786 |\n"); 31 | printf("| |\n"); 32 | printf("| UNIFEI |\n"); 33 | printf("---------------------------------------\n"); 34 | } 35 | -------------------------------------------------------------------------------- /2749.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | printf("---------------------------------------\n"); 28 | printf("|x = 35 |\n"); 29 | printf("| |\n"); 30 | printf("| x = 35 |\n"); 31 | printf("| |\n"); 32 | printf("| x = 35|\n"); 33 | printf("---------------------------------------\n"); 34 | } 35 | -------------------------------------------------------------------------------- /2826.java: -------------------------------------------------------------------------------- 1 | 2 | package problemsolving; 3 | 4 | import java.util.Scanner; 5 | 6 | public class ProblemSolving { 7 | 8 | /** 9 | * @param args the command line arguments 10 | */ 11 | public static void main(String[] args) { 12 | // TODO code application logic here 13 | 14 | Scanner input = new Scanner(System.in); 15 | 16 | String A,B; 17 | 18 | A = input.nextLine(); 19 | 20 | B = input.nextLine(); 21 | 22 | if(A.compareTo(B)==0) 23 | { 24 | System.out.println(A); 25 | System.out.println(B); 26 | } 27 | else if(A.compareTo(B)<0) 28 | { 29 | System.out.println(A); 30 | System.out.println(B); 31 | } 32 | else if(A.compareTo(B)>0) 33 | { 34 | System.out.println(B); 35 | System.out.println(A); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /2936.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include // Common file 3 | #include 4 | #include // for less 5 | #include 6 | using namespace __gnu_pbds; 7 | using namespace std; 8 | 9 | typedef long long ll; 10 | 11 | #define pf(n) cout << n << endl 12 | #define ps() cout <<" "; 13 | #define sf(n) cin >> n 14 | #define in(i,n) for (int i = 0; i < n; i++) 15 | #define vi vector 16 | #define vp vector> 17 | #define graph vector< vector > 18 | #define vs vector 19 | #define mn - 20 | #define mod % 21 | #define E = 22 | #define EE == 23 | int mx=9999999; 24 | /** '' "\n" - ^ **/ 25 | int main() { 26 | ios::sync_with_stdio(false); 27 | cin.tie(0); 28 | ll sum=225; 29 | int a[]={300,1500,600,1000,150}; 30 | for(int i=0;i<5;i++) 31 | { 32 | int x; 33 | cin>>x; 34 | sum+=(a[i]*x); 35 | } 36 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int x,y; 8 | int count=0,in=0,g=0,d=0; 9 | int c=1; 10 | while(c==1) 11 | { 12 | count++; 13 | cin>>x>>y; 14 | if(x>y) 15 | in++; 16 | if(y>x) 17 | g++; 18 | if(x==y) 19 | d++; 20 | while(1) 21 | { 22 | cin>>c; 23 | if(c>=1&&c<=2) 24 | { 25 | break; 26 | } 27 | cout<<"Novo grenal (1-sim 2-nao)\n"; 28 | } 29 | cout<<"Novo grenal (1-sim 2-nao)\n"; 30 | } 31 | cout<g) 36 | cout<<"Inter venceu mais\n"; 37 | if(in 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | #define ll long long 18 | #define input scanf 19 | #define output printf 20 | #define Loop while 21 | #define echo cout 22 | #define ret return 23 | #define MAX 999999999999999999 24 | #define MIN 0 25 | map mp; 26 | map::iterator it; 27 | void sieve(); 28 | vector x(31); 29 | int main(int argc, char** argv) { 30 | 31 | //freopen("c.txt","w",stdout); 32 | sieve(); 33 | int n; 34 | int i=1; 35 | while(cin>>n&&n) 36 | { 37 | printf("Teste %d\n",i++); 38 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string str; 6 | while(getline(cin,str)) 7 | { 8 | long long sum=0; 9 | for(int i=0;i=65&&str[i]<=90) 12 | { 13 | int f=(str[i]-64)%9; 14 | if(f==0) 15 | f=9; 16 | sum+=f; 17 | } 18 | if(str[i]>=97&&str[i]<=122) 19 | { 20 | int f=(str[i]-96)%9; 21 | if(f==0) 22 | f=9; 23 | sum+=f; 24 | } 25 | } 26 | long long copy=sum; 27 | while(true) 28 | { 29 | if(copy<10) 30 | break; 31 | long long h=0; 32 | while(copy!=0) 33 | { 34 | h+=(copy%10); 35 | copy=copy/10; 36 | } 37 | copy=h; 38 | } 39 | printf("%d\n",copy); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /2747.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace std; 20 | 21 | typedef long long ll; 22 | typedef std::vector vi; 23 | 24 | #define PI acos(-1) 25 | #define E 2.718281828459 26 | 27 | int main(int argc, char** argv) { 28 | printf("---------------------------------------\n"); 29 | printf("| |\n"); 30 | printf("| |\n"); 31 | printf("| |\n"); 32 | printf("| |\n"); 33 | printf("| |\n"); 34 | printf("---------------------------------------\n"); 35 | } 36 | -------------------------------------------------------------------------------- /1547.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | 8 | while(t-->0) 9 | { 10 | int n; 11 | cin>>n; 12 | int num; 13 | cin>>num; 14 | int c[n]; 15 | for(int i=0;i>z; 19 | if(num>=z) 20 | { 21 | c[i]=num-z; 22 | } 23 | else 24 | { 25 | c[i]=z-num; 26 | } 27 | } 28 | int l=c[0]; 29 | int r; 30 | for(int i=1;i 2 | using namespace std; 3 | int main() 4 | { 5 | string x[100]; 6 | int N,M; 7 | while(cin>>N>>M&&N&&M) 8 | { 9 | cin.ignore(); 10 | for(int i=0;i>x[i]; 12 | //cout<>n>>m; 16 | int height=(n/N); 17 | int width=(m/M); 18 | for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b; 6 | int I=1; 7 | while(cin>>a>>b&&a&&b) 8 | { 9 | if(a<=b)printf("Case %d: 0\n",I++); 10 | else 11 | { 12 | int d=a/b; 13 | if(d>=27) 14 | { 15 | if(d>27) 16 | printf("Case %d: impossible\n",I++); 17 | else 18 | { 19 | if(a%b==0){ 20 | d--; 21 | printf("Case %d: %d\n",I++,d); 22 | } 23 | else 24 | { 25 | printf("Case %d: impossible\n",I++); 26 | } 27 | } 28 | } 29 | else 30 | { 31 | if(a%b==0) 32 | d--; 33 | printf("Case %d: %d\n",I++,d); 34 | 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /1577.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t,n; 6 | cin>>t; 7 | while(t--) 8 | { 9 | cin>>n; 10 | if(n%3==0) 11 | n=n/3; 12 | if(n%5==0) 13 | n=n/5; 14 | if(n%17==0) 15 | n=n/17; 16 | if(n%257==0) 17 | n=n/257; 18 | if(n%65537==0) 19 | n=n/65537; 20 | for(int i=0;;i++) 21 | { 22 | if(n==(int)pow(2.0,(double)i)) 23 | { 24 | cout<<"Yes"< 2 | using namespace std; 3 | 4 | typedef unsigned long long ll; 5 | vector > a(51000); 6 | vector v(51000); 7 | vector ans; 8 | void dfs(int n) 9 | { 10 | if(v[n])return; 11 | v[n]=true; 12 | for(auto e:a[n]) 13 | { 14 | dfs(e); 15 | } 16 | ans.push_back(n); 17 | return; 18 | } 19 | 20 | int main() 21 | { 22 | int n,m; 23 | int u,vi; 24 | while(cin>>m>>n) 25 | { 26 | 27 | fill(v.begin(),v.end(),false); 28 | int x,y,z; 29 | int i=1; 30 | while(n--) 31 | { 32 | cin>>x>>y; 33 | a[x].push_back(y); 34 | a[y].push_back(x); 35 | } 36 | //cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | int t; 8 | cin>>t; 9 | int sum=0; 10 | char a[1111]; 11 | for(int j=1;j<=t;j++) 12 | { 13 | cin>>a; 14 | for(int i=0;i 2 | #include // Common file 3 | #include 4 | #include // for less 5 | #include 6 | using namespace __gnu_pbds; 7 | using namespace std; 8 | 9 | typedef long long ll; 10 | 11 | #define pf(n) cout << n << endl 12 | #define ps() cout <<" "; 13 | #define sf(n) cin >> n 14 | #define in(i,n) for (int i = 0; i < n; i++) 15 | #define vi vector 16 | #define vp vector> 17 | #define graph vector< vector > 18 | #define vs vector 19 | #define mn - 20 | #define mod % 21 | #define E = 22 | #define EE == 23 | int mx=9999999; 24 | /** '' "\n" - ^ **/ 25 | int main() { 26 | ios::sync_with_stdio(false); 27 | cin.tie(0); 28 | int n; 29 | cin>>n; 30 | cout<<"Ent"; 31 | in(i,n) 32 | cout<<"a"; 33 | cout<<"o eh N"; 34 | in(i,n) 35 | cout<<"a"; 36 | cout<<"t"; 37 | in(i,n) 38 | cout<<"a"; 39 | cout<<"l!"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 17 | using namespace std; 18 | 19 | typedef long long ll; 20 | 21 | #define PI acos(-1) 22 | #define e 2.718281828459 23 | 24 | int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } 25 | int main(int argc, char** argv) { 26 | //freopen("c.txt","w",stdout); 27 | int n,m; 28 | int h; 29 | while(cin>>n>>m) 30 | { 31 | vector a; 32 | for(int i=0;i>h; 35 | a.push_back(h); 36 | } 37 | int sum=0; 38 | int i=a.size()-1; 39 | while(m--) 40 | { 41 | sum+=a[i--]; 42 | } 43 | cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n; 7 | while(cin>>n) 8 | { 9 | int m,l; 10 | cin>>m>>l; 11 | vectorM[m]; 12 | vectorL[l]; 13 | for(int i=0;i>a; 19 | M[i].push_back(a); 20 | } 21 | } 22 | for(int i=0;i>a; 28 | L[i].push_back(a); 29 | } 30 | } 31 | int MM,LL;cin>>MM>>LL; 32 | int A; 33 | cin>>A; 34 | long long s=M[MM-1][A-1]; 35 | long long S=L[LL-1][A-1]; 36 | if(s>S) cout<<"Marcos\n"; 37 | else if(s 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | cin.ignore(); 8 | string c; 9 | while(t--) 10 | { 11 | cin>>c; 12 | string temp; 13 | int sum=0; 14 | for(int i=0;i<14;i++) 15 | { 16 | if(c[i]>=48&&c[i]<=57) 17 | temp=temp+c[i]; 18 | else 19 | { 20 | if(!temp.empty()) 21 | { 22 | stringstream geek(temp); 23 | int f=0; 24 | geek>>f; 25 | temp.clear(); 26 | sum+=f; 27 | } 28 | } 29 | } 30 | if(!temp.empty()) 31 | { 32 | stringstream geek(temp); 33 | int f=0; 34 | geek>>f; 35 | temp.clear(); 36 | sum+=f; 37 | } 38 | //cin>>c; 39 | printf("%d\n",sum); 40 | } 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /2154.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | freopen("uri.txt","w",stdout); 5 | int n; 6 | while(cin>>n) 7 | { 8 | string a,b; 9 | int count=0; 10 | while(true) 11 | { 12 | cin>>a; 13 | string temp; 14 | int c=0,d=0; 15 | for(int i=0;i>c; 21 | temp.clear(); 22 | } 23 | else temp=temp+a[i]; 24 | } 25 | stringstream o(temp); 26 | o>>d; 27 | if(d!=2) 28 | printf("%dx%d",c*d,d-1); 29 | else printf("%dx",c*d); 30 | count++; 31 | if(count==n)break; 32 | cin>>b; 33 | printf(" + "); 34 | } 35 | printf("\n"); 36 | } 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /2567.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 17 | using namespace std; 18 | 19 | typedef long long ll; 20 | 21 | #define PI acos(-1) 22 | #define e 2.718281828459 23 | 24 | int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } 25 | int main(int argc, char** argv) { 26 | //freopen("c.txt","w",stdout); 27 | int n; 28 | while(cin>>n) 29 | { 30 | vector a(n); 31 | for(int i=0;i>a[i]; 34 | } 35 | sort(a.begin(),a.end()); 36 | int sum=0; 37 | int i=0; 38 | int j=n-1; 39 | while(j>i) 40 | { 41 | sum+=abs(a[i++]-a[j--]); 42 | } 43 | printf("%d\n",sum); 44 | } 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /1800.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | #define ll long long 18 | #define input scanf 19 | #define output printf 20 | #define Loop while 21 | #define echo cout 22 | #define ret return 23 | //#define MAX 999999999999999999 24 | #define MIN 0 25 | map mp; 26 | map::iterator it; 27 | void sieve(); 28 | int main(int argc, char** argv) { 29 | 30 | //freopen("c.txt","w",stdout); 31 | int q,e; 32 | cin>>q>>e; 33 | vector a(1001); 34 | fill(a.begin(),a.end(),false); 35 | int xx; 36 | for(int i=0;i>xx; 39 | a[xx]=true; 40 | } 41 | for(int i=0;i>xx; 44 | if(a[xx]==false) 45 | { 46 | a[xx]=true; 47 | cout<<1< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | typedef long long ll; 21 | typedef std::vector vi; 22 | 23 | #define PI acos(-1) 24 | #define E 2.718281828459 25 | 26 | int main(int argc, char** argv) { 27 | int DD,MM,YY; 28 | scanf("%d/%d/%d",&DD,&MM,&YY); 29 | if(MM<10)cout<<0; 30 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | int main(){ 6 | char str[100]; 7 | while(gets(str)){ 8 | bool x=false,y=false,z=false; 9 | int length=strlen(str); 10 | if(length<6||length>32) 11 | cout<<"Senha invalida.\n"; 12 | else{ 13 | bool p=true; 14 | for(int i=0;i=65&&str[i]<=90) 16 | x=true; 17 | else if(str[i]>=97&&str[i]<=122) 18 | y=true; 19 | else if(str[i]>=48&&str[i]<=57) 20 | z=true; 21 | else{ 22 | p=false; 23 | break; 24 | } 25 | } 26 | if(x&&y&&z&&p) 27 | cout<<"Senha valida.\n"; 28 | else 29 | cout<<"Senha invalida.\n"; 30 | } 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /2708.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | using namespace std; 16 | 17 | 18 | #define ll long long 19 | #define input scanf 20 | #define output printf 21 | #define Loop while 22 | #define echo cout 23 | #define ret return 24 | #define MAX 999999999999999999 25 | #define MIN 0 26 | #define PI 3.1415 27 | 28 | bool isPrime(int x); 29 | void sieve(); 30 | string toBinary(int n); 31 | bool findingSubString(string a,string b); 32 | vector a(32); 33 | int main(int argc, char** argv) { 34 | 35 | //freopen("c.txt","w",stdout); 36 | string str; 37 | int a; 38 | int sum=0; 39 | int out=0; 40 | while(cin>>str&&str[0]!='A') 41 | { 42 | cin>>a; 43 | if(str[0]=='S') 44 | { 45 | out++; 46 | sum+=a; 47 | } 48 | else 49 | { 50 | out--; 51 | sum-=a; 52 | } 53 | } 54 | printf("%d\n%d\n",sum,out); 55 | ret 0; 56 | } 57 | -------------------------------------------------------------------------------- /2163.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int N,M; 6 | cin>>N>>M; 7 | int a[N][M]; 8 | for(int i=0;i>a[i][j]; 12 | } 13 | int x_axis=0,y_axis=0; 14 | bool x=false; 15 | for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | int I=1; 8 | double a[3]; 9 | string str; 10 | while(t--) 11 | { 12 | cin>>str; 13 | cin>>a[0]>>a[1]>>a[2]; 14 | if(str[0]=='e') 15 | { 16 | a[0]=(a[0]*30)/100; 17 | a[1]=(a[1]*59)/100; 18 | a[2]=(a[2]*11)/100; 19 | a[0]=a[0]+a[1]+a[2]; 20 | int f=a[0]; 21 | printf("Caso #%d: %d\n",I++,f); 22 | } 23 | else if(str.length()==4) 24 | { 25 | int m=(a[0]+a[1]+a[2])/3; 26 | printf("Caso #%d: %d\n",I++,m); 27 | } 28 | else 29 | { 30 | sort(a,a+3); 31 | if(str[1]=='i') 32 | { 33 | int f=a[0]; 34 | printf("Caso #%d: %d\n",I++,f); 35 | } 36 | else 37 | { 38 | int f=a[2]; 39 | printf("Caso #%d: %d\n",I++,f); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /2084.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n; 7 | cin>>n; 8 | int a[n]; 9 | int votes=0; 10 | for(int i=0;i>a[i]; 12 | votes+=a[i]; 13 | } 14 | sort(a,a+n); 15 | double x,y,Z; 16 | int p=n-1; 17 | x=(45*votes*1.00)/100; 18 | y=(40*votes*1.00)/100; 19 | Z=(10*votes*1.00)/100; 20 | if(a[n-1]>=x) 21 | cout<<"1\n"; 22 | else if(a[p]=y) 25 | { 26 | bool z=false; 27 | double div; 28 | for(int i=0;i=Z) 33 | { 34 | continue; 35 | } 36 | else 37 | { 38 | z=true; 39 | break; 40 | } 41 | } 42 | if(z) 43 | cout<<"2\n"; 44 | else 45 | cout<<"1\n"; 46 | } 47 | return 0; 48 | } 49 | 50 | 51 | --------------------------------------------------------------------------------