by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <stdio.h>
int main ()
{
int problem1,prblm [20],required [20],tc = 0;
while ( scanf ("%d", &problem1)== 1 ) {
if ( problem1 < 0 )
return 0;
prblm [0] = problem1;
int i;
for ( i = 1; i < 13; i++ )
scanf ("%d", &prblm [i]);
for ( i = 0; i < 12; i++ )
scanf ("%d", &required [i]);
printf ("Case %d:\n", ++tc);
for ( i = 0; i < 12; i++ ) {
if ( problem1 >= required [i] ) {
problem1 -= required [i];
printf ("No problem! :D\n");
}
else
printf ("No problem. :(\n");
problem1 += prblm [i + 1];
}
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include<bits/stdc++.h>
using namespace std;
int main ()
{
int p ,i, n ,l;
int c = 0;
while(cin>>n)
{
if(n<0)
{
break;
}
else
{
for(i=0;i<n;i++)
{
l=pow(2,i);
if(l>=n)
break;
}
}
printf("Case %d: %d\n",c+1,i);
c++;
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include<bits/stdc++.h>
bool flag[10000000];
long long int List[200000],primes[10000017];
int listSize,cnt,loc;
using namespace std;
void sieve(int n)
{
cnt=0;
primes[cnt++]=2;
for(int i=3;i<=n;i+=2)
{
if(flag[i]==0)
{
primes[cnt++]=i;
}
if(i<=n/i)
{
for(int j=i*i;j<=n;j+=2*i)
{
flag[j]=1;
}
}
}
return ;
}
void primeFactorize(long long int n,int loc)
{
listSize=0;
for(int i=0;i<loc;i++)
{
if(n%primes[i]==0)
{
while(n%primes[i]==0)
{
n/=primes[i];
List[listSize++]=primes[i];
}
}
}
if(n>1)
List[listSize++]=n;
return ;
}
int main()
{
long long int n;
sieve(10000000);
while(scanf("%lld",&n)==1)
{
loc=0;
if(n==0)
return 0;
else if(n<0)
n=(-1)*n;
for(int i=0;i<cnt;i++)
{
if(primes[i]<=sqrt(n))
loc++;
else
break;
}
primeFactorize(n,loc);
//cout<<"pos"<<pos<<endl;
if(listSize <= 1 || List[listSize-1]-List[0]==0)
printf("-1\n");
else
printf("%lld\n",List[listSize-1]);
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc, hour, mint;
cin>>tc;
while(tc--)
{
scanf("%d:%d", &hour, &mint);
hour= 11-hour + (mint == 0);
if(hour <= 0)
hour=hour+12;
if(mint != 0)
mint = 60-mint;
printf("%02d:%02d\n",hour,mint);
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int h1,m1,h2,m2;
while(cin>>h1>>m1>>h2>>m2)
{
if(h1==0 && m1==0 && h2==0 && m2==0) break;
h1*=60;
h1+=m1;
h2*=60;
h2+=m2;
cout<<abs(h2-h1)<<endl;
}
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int e,f,t,div,ate,val,c,rem;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d",&e,&f,&c);
ate=0;
val=e+f;
while(val>=c)
{
div=val/c;
ate+=div;
rem=val%c;
val=div+rem;
}
printf("%d\n",ate);
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <string.h>
#include <stdio.h>
char s1[1000],s2[1000],n1[1000],n2[1000];
int main()
{
char l,m,g,h;
int t,i,j,k,r;
scanf("%d%*c",&t);
while(t--)
{
gets(s1);
gets(s2);
l=strlen(s1);
m=strlen(s2);
if(l==m)
{
g=0,h=0;
for(k=0;k<l;k++)
{
if(s1[k]=='a'||s1[k]=='e'||s1[k]=='i'||s1[k]=='o'||s1[k]=='u')
continue;
else
n1[g]=s1[k];
g++;
}
n1[g]='\0';
for(r=0;r<m;r++)
{
if(s2[r]=='a'||s2[r]=='e'||s2[r]=='i'||s2[r]=='o'||s2[r]=='u')
continue;
else
n2[h]=s2[r];
h++;
}
n2[h]='\0';
if(strcmp(n1,n2)==0)
printf("Yes\n");
else printf("No\n");
}
else
printf("No\n");
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
char s[10009];
float sq;
int k,len,num,i,j,temp;
cin>>num;
while(num--)
{
scanf("\r");
gets(s);
len=strlen(s);
sq=sqrt(len);
int p=(int)sq;
char ch[p][p];
if(p == sq)
{
int n=0;
for(i=0;i<p;i++)
{
for(j=0;j<p;j++)
{
ch[i][j]=s[n++];
//printf("%c",ch[j][i]);
}
}
for(i=0;i<p;i++)
{
for(j=0;j<p;j++)
{
printf("%c",ch[j][i]);
}
}
cout<<"\n";
}
else
{
cout<<"INVALID"<<endl;
}
//l=strlen(s);
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <stdio.h>
#include <string.h>
int main()
{
char s1[500],s2[500],s1s[500],s2s[500];
int t,i,j,k;
scanf("%d ",&t);
for(i=0;i<t;i++){
gets(s1);
gets(s2);
if(strcmp(s1,s2)==0)printf("Case %d: Yes\n",i+1);
else {
k=0;
for(j=0;j<strlen(s1);j++){
if(s1[j]!=' '){
s1s[k]=s1[j];
k++;
}
}
s1s[k]='\0';
k=0;
for(j=0;j<strlen(s2);j++){
if(s2s[j]!=' '){
s2s[k]=s2[j];
k++;
}
}
s2s[k]='\0';
if(strcmp(s1s,s2s)==0)printf("Case %d: Output Format Error\n",i+1);
else printf("Case %d: Wrong Answer\n",i+1);
}
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc,n,c,a[51],i;
cin>>tc;
for(int j=1;j<=tc;j++)
{
cin>>n;
int h=0;
int l=0;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n-1;i++)
{
if(a[i+1]>a[i])
{
h++;
}
else if(a[i+1]<a[i])
{
l++;
}
}
printf("Case %d: %d %d\n",j,h,l);
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t1,t2,f,a,ct1,ct2,ct3,sum,avr,c,t;
cin>>t;
for(c=0;c<t;c++)
{
sum=0;
cin>>t1>>t2>>f>>a>>ct1>>ct2>>ct3;
{
if(ct1<=ct2 && ct1<=ct3)
avr=(ct2+ct3)/2;
if(ct2<=ct1 && ct2<=ct3)
avr=(ct1+ct3)/2;
if(ct3<=ct1 && ct3<=ct2)
avr=(ct1+ct2)/2;
sum=t1+t2+f+a+avr;
if(sum>=90)
printf("Case %d: A\n",c+1);
else if(sum>=80)
printf("Case %d: B\n",c+1);
else if(sum>=70)
printf("Case %d: C\n",c+1);
else if(sum>=60)
printf("Case %d: D\n",c+1);
else if(sum<60)
printf("Case %d: F\n",c+1);
}
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int e,a;
while(cin>>a)
{
if(a==0) break;
e=0;
while(a>=3)
{
a=a-3;
e++;
a++;
}
if(a==2)
{
cout<<e+1<<endl;
}
else
cout<<e<<endl;
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,p,result,tc,i,j,c=0;
while(cin>>tc)
{
while(tc--)
{
cin>>n>>k>>p;
result=k+p;
while(result>n)
{
result-=n;
}
printf("Case %d: %d\n",c+1,result);
c++;
}
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, array[10], c, d, t;
while(cin>>array[0]>>array[1]>>array[2])
{
if(array[0]==0 and array[1]==0 and array[2]==0) break;
for (c = 0 ; c <= 2; c++) {
d = c;
while ( d > 0 && array[d] < array[d-1]) {
t = array[d];
array[d] = array[d-1];
array[d-1] = t;
d--;
}
}
int x=array[0];
int y=array[1];
int z=array[2];
if(pow(x,2) + pow(y,2)==pow(z,2))
{
printf("right\n");
}
else
printf("wrong\n");
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
char input[1050];
int main()
{
int i,j,l,rem,total;
while(1)
{
l=strlen(gets(input));
rem=0;
if(l==1 and input[0]=='0') break;
for(i=0;i<l;i++)
{
total=rem*10 + (input[i] - '0');
rem=total%17;
//these two eqn same rem=(rem*10 + (input[i] - '0'))%17;
}
if(rem==0) cout<<"1\n";
else
cout<<"0\n";
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include<bits/stdc++.h>
using namespace std;
int main()
{
int tc,n,p,q,b,i,j,a[30],sum,sr=1,egg,wt;
while(cin>>tc)
{
for(j=1;j<=tc;j++)
{
cin>>n>>p>>q;
for(i=0;i<n;i++)
{
cin>>a[i];
}
egg=0,wt=0;
for(i=0;i<n;i++)
{
if(egg<p and wt+a[i]<=q)
{
egg++;
//printf("he %d",egg);
wt+=a[i];
}
}
printf("Case %d: %d\n",sr++,egg);
}
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int tc=1;
while(n--)
{
int input;
cin>>input;
map<string,int>m;
string s;
int d;
for(int i=1;i<=input;i++)
{
cin>>s>>d;
m[s]=d;
}
int D;
cin>>D;
string k;
cin>>k;
printf ("Case %d: ", tc++);
if ( m [k] && m [k] <= D )
printf ("Yesss\n");
else if ( m [k] && m [k] <= D + 5 )
printf ("Late\n");
else
printf ("Do your own homework!\n");
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
unsigned long int d,q;
int i,count,j,bn[1000];
while(scanf("%lu",&d)==1)
{
if(d==0) break;
i=0;
q=d;
while(q!=0)
{
bn[i++]= q%2;
q/=2;
}
count=0;
printf("The parity of ");
for(j=i-1;j>=0;j--)
{
printf("%d",bn[j]);
if(bn[j]==1)
count++;
}
printf(" is %d (mod 2).\n",count);
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,l,fn,count;
while(cin>>a>>b>>c>>d>>l)
{
if(a==0 and b==0 and c==0 and d==0 and l==0) break;
count=0;
for(int i=0;i<=l;i++)
{
fn=a*i*i + b*i +c;
if(fn%d==0)
count++;
}
cout<<count<<endl;
}
return 0;
}
by Jesmin Akther | Jan 1, 2019 | Problem Solving, UVa
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc,a,b,c;
cin>>tc;
while( tc-- )
{
cin>>a>>b>>c;
if( a+b>c and b+c>a and c+a>b)
cout<<"OK"<<endl;
else
cout<<"Wrong!!"<<endl;
}
return 0;
}