URI Oj Problem 1038 & 1165

URI Oj Problem 1038 : Porblem link 


#include<stdio.h>
int main()
{
float n1=4,n2=4.50,n3=5,n4=2,n5=1.5,tmp;
int i,j,a,b,n,m,q;
while(scanf("%d %d",&n,&q)==2){
if(n==1){
tmp=q*n1;
printf("Total: R$ %.2f\n",tmp);
}
if(n==2){
tmp=q*n2;
printf("Total: R$ %.2f\n",tmp);
}
if(n==3){
tmp=q*n3;
printf("Total: R$ %.2f\n",tmp);
}
if(n==4){
tmp=q*n4;
printf("Total: R$ %.2f\n",tmp);
}
if(n==5){
tmp=q*n5;
printf("Total: R$ %.2f\n",tmp);
}
}
}
view raw URI 1038 hosted with ❤ by GitHub


URI Oj Problem 1165 : Problem link


#include<stdio.h>
#include<math.h>
int main()
{
int i,j,k,root,n,count=0;
while(scanf("%d",&k)==1){
for(i=1;i<=k;i++){
scanf("%d",&n);
if(n==1 || n==0)
printf("%d nao eh primo\n",n);
else {
count=0;
root=sqrt(n);
for(j=2;j<=root;j++){
if(n%j==0){
count=1;
break;
}
}
if(count==1)
printf("%d nao eh primo\n",n);
else
printf("%d eh primo\n",n);
count=0;
}
}
}
}
view raw 1165 hosted with ❤ by GitHub