Temperature
TODOLIST
TJU 1748. Power Digit January 27, 2010
TJU 1748. Power Digit
TODOLIST
Output Limit Exceed
#include<iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
class A{
int m,n,i,j,k,rem,res;
public:
void input(){
cin>>m>>n;
if(m==0&&n==0) exit(0);
}
void calc(){
rem=m%10;
switch(rem){
case 1:
res=1;
break;
case 2:
i=n%4;if(i==0) i=4;
res=pow(2,i);
break;
case 3:
i=n%4;if(i==0) i=4;
res=pow(3,i);
break;
case 4:
i=n%2;if(i==0) i=2;
res=pow(4,i);
break;
case 5:
res=5;
break;
case 6:
res=6;
break;
case 7:
i=n%4;if(i==0) i=4;
res=pow(7,i);
break;
case 8:
i=n%4;if(i==0) i=4;
res=pow(8,i);
break;
case 9:
i=n%2;if(i==0) i=2;
res=pow(9,i);
break;
case 0:
res=0;
break;
}
}
void output(){
cout<<(res%10)<<endl;
}
};
int main()
{
A obj;
while(1){
obj.input();
obj.calc();
obj.output();
}
return 0;
}
TJU 2498. Uncle Jack January 20, 2010
TJU 2498. Uncle Jack
TODOLIST
WRONG ANSWER
{big multiplication based question}
#include<iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
class A{
long long i,j,N,D,R;
public:
void input(){
cin>>N>>D;
if(N==0&&D==0) exit(0);
}
void output(){
R=powf(N,D);
cout<<R<<endl;
}
};
int main()
{
A a;
while(1){
a.input();
a.output();
}
return 0;
}
TJU 3016. Decode the Strings January 13, 2010
Cryptography practise
TJU 3016. Decode the Strings
TODO[medium]
SPOJ 78. Marbles December 7, 2009
SPOJ 78. Marbles
Problem code: MARBLES
TODOLIST:
–AC–
#include<iostream>
#include<stdlib.h>
using namespace std;
class A{
long long int i,j,k,N,K,tmp;
public:
void input(){
cin>>N>>K;
N--;
K--;
}
void calc(){
i=N-K;
if(N==K||K==0) {tmp=1;}
else if(K==1){tmp=N;}
else if(i>K)
{
j=1;
tmp=1;
while(j<=K)
{
if(N%j==0)
tmp=tmp*(N/j);
else if(tmp%j==0)
tmp=N*(tmp/j);
else tmp=(N*tmp)/j;
j++;
N--;
}
}
else if(i<=K)
{
j=1;
tmp=1;
while(j<=i)
{
if(N%j==0)
tmp=tmp*(N/j);
else if(tmp%j==0)
tmp=N*(tmp/j);
else tmp=(N*tmp)/j;
j++;
N--;
}
}
}
void output(){
cout<<tmp<<endl;
}
};
int main()
{
A a;
int T;
cin>>T;
while(T--){
a.input();
a.calc();
a.output();
}
return 0;
}
TJU 2830. Bronze Cow Party November 14, 2009
TJU 2830. Bronze Cow Party
—NOT DONE–
[its a Dikstra algo based question]
Sol -link



Recent Comments