#include <bits/stdc++.h> using namespace std; #define ld long long ld ModInv(ld b, ld n){ ld r1=n,r2=b,t1=0,t2=1; while(r2>0){ ld q=r1/r2; ld r=r1-q*r2; r1=r2;r2=r; ld t=t1-q*t2; t1=t2;t2=t; } if(t1<0)t1+=n; return t1; } ld powerLL(ld x, ld n, ld MOD) { ld result = 1; while (n) { if (n&1) result = result * x % MOD; n = n / 2; x = x * x % MOD; } return result; } ld powerStrings(string sa, string sb, ld MOD) { ld a = 0, b = 0; for (int i = 0; i < sa.length(); i++) a = (a * 10 + (sa[i] - '0')) % MOD; for (int i = 0; i < sb.length(); i++) b = (b * 10 + (sb[i] - '0')) % (MOD - 1); return powerLL(a, b, MOD); } ld mod(string num, ld a) { ld res = 0; // One by one process all digits of 'num' for (int i = 0; i < num.length(); i++) res = (res*10 + (int)num[i] - '0') %a; return res; } int main(){ ld p=709,q=59,e0,d=14,r=13,hm=100; // cin>>p>>q>>e0>>d>>hm>>r; ld a,b,t,e1,e2,s1,s2,v; // for(int i=1;i<=708;i++){ e0=187; e1=powerStrings(to_string(e0),to_string((p-1)/q),p);if(e1<0)e1+=p; e2=powerStrings(to_string(e1),to_string(d),p);if(e2<0)e2+=p; s1=powerStrings(to_string(e1),to_string(r),p);if(s1<0)s1+=p; s1=s1%q; s2=(((hm%q+(d*s1)%q)%q)*ModInv(r,q))%q; //////////// V a=powerStrings(to_string(e1),to_string(hm*ModInv(s2,q)),p); b=powerStrings(to_string(e2),to_string(s1*ModInv(s2,q)),p); v=(a*b)%q; // if(s1==v)cout<<e0<<"\n"; cout<<"e1="<<e1<<"\n"; cout<<"e2="<<e2<<"\n"; cout<<"s1="<<s1<<"\n"; cout<<"s2="<<s2<<"\n"; cout<<"v="<<v<<"\n"; // } } // 1 // 61 // 63 // 64 // 85 // 91 // 96 // 120 // 121 // 152 // 176 // 184 // 187 // 227 // 228 // 237 // 248 // 272 // 285 // 291 // 297 // 298 // 333 // 348 // 361 // 376 // 411 // 412 // 418 // 424 // 437 // 461 // 472 // 481 // 482 // 522 // 525 // 533 // 557 // 588 // 589 // 613 // 618 // 624 // 645 // 646 // 648 // 708
Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++
and start coding!
OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << "Enter name:";
getline (cin, name);
cout << "Hello " << name;
return 0;
}
C++ is a widely used middle-level programming language.
When ever you want to perform a set of operations based on a condition If-Else is used.
if(conditional-expression) {
//code
}
else {
//code
}
You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.
Switch is an alternative to If-Else-If ladder.
switch(conditional-expression){
case value1:
// code
break; // optional
case value2:
// code
break; // optional
......
default:
code to be executed when all the above cases are not matched;
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while (condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.
return_type function_name(parameters);
function_name (parameters)
return_type function_name(parameters) {
// code
}