Problem Name : Flavious Josephus Legend
Solution :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int josephus(int n,int k); | |
int main() | |
{ | |
int tcase,n,k,i; | |
while(scanf("%d",&tcase)==1){ | |
for(i=1;i<=tcase;i++){ | |
scanf("%d %d",&n,&k); | |
int tmp=josephus(n,k); | |
printf("Case %d: %d\n",i,tmp); | |
} | |
} | |
return 0; | |
} | |
int josephus(int n,int k) | |
{ | |
if(n==1) | |
return 1; | |
else | |
return (josephus(n-1,k)+k-1)%n+1; | |
} |
Problem No : 1116
Problem Name : Dividing X by Y
Solution :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int t,n,m; | |
double d; | |
scanf("%d",&t); | |
while(t--){ | |
scanf("%d %d",&n,&m); | |
if(m==0) | |
printf("divisao impossivel\n"); | |
else{ | |
d=(double) n/m; | |
printf("%.1lf\n",d); | |
} | |
} | |
return 0; | |
} |
Problem No : 1096
Problem Name : Sequence IJ 2
Solution :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int i,j; | |
for(i=1;i<=9;i=i+2){ | |
for(j=7;j>=5;j--){ | |
printf("I=%d J=%d\n",i,j); | |
} | |
} | |
return 0; | |
} | |