F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
Notice:1:注册本OJ方式请见https://www.lydsy.com/JudgeOnline/wttl/thread.php?tid=5671 2:请不要在讨论区中发空白主题帖。
大视野在线测评-欢迎您
[ New Thread ]
Problem 5352 >> 原版Lemon的spj
lavendir @ 2018-05-26 11:53:33
[ Quote ] [ Edit ] [ Delete ] 1#
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long int64;

FILE *Finn, *Fout, *Fres, *Fmsg;
double fullScore;

void Return(double p, char* s)
{
fprintf(Fres, "%.3lf", p*fullScore);
fprintf(Fmsg, "%s", s);
exit(0);
}

char s[10000005];
long long n1,n2,x,m,p;
int i,j,k,l;

long long Power(long long a,long long b,long long p)
{
long long ans=1;
while(b)
{
if(b&1)ans=ans*a%p;
a=a*a%p;
b>>=1;
}
return ans;
}

int main(int args, char** argv)
{
Finn = fopen(argv[1], "r");
Fout = fopen(argv[2], "r");
sscanf(argv[4], "%lf", &fullScore);
Fres = fopen(argv[5], "w");
Fmsg = fopen(argv[6], "w");

fscanf(Finn,"%lld%lld%lld",&x,&m,&p);
fscanf(Fout,"%s",s+1);
l=strlen(s+1);
if(l==0)Return(0.0,"No Output");
for(i=1;i<=l;++i)
{
if(s[i]<'0'||s[i]>'9')Return(0.0,"Strange Output");
n1=(n1*10+s[i]-'0')%p;
n2=(n2*10+s[i]-'0')%(p-1);
}
if((Power(n1,2*n2,p)+Power(n1,m,p))%p==x)Return(1.0,"Accept");
else Return(0.0,"Wrong Answer");

return 0;
}


[Top] [Previous Page] [Next Page]

HOME Back