__int128不支持cin,cout,scanf,printf对其定义的变量的输入输出,需自己另写输入输出函数。
模板:
void scan(__int128 &x)//输入
{
x = 0;
int f = 1;
char ch;
if((ch = getchar()) == '-') f = -f;
else x = x*10 + ch-'0';
while((ch = getchar()) >= '0' && ch <= '9')
x = x*10 + ch-'0';
x *= f;
}
void _print(__int128 x)
{
if(x > 9) _print(x/10);
putchar(x%10 + '0');
}
void print(__int128 x)//输出
{
if(x < 0)
{
x = -x;
putchar('-');
}
_print(x);
}
实战
https://www.acwing.com/problem/content/92/
#include <bits/stdc++.h>
using namespace std;
void scan(__int128 &x)//输入
{
x = 0;
int f = 1;
char ch;
if((ch = getchar()) == '-') f = -f;
else x = x*10 + ch-'0';
while((ch = getchar()) >= '0' && ch <= '9')
x = x*10 + ch-'0';
x *= f;
}
void _print(__int128 x)
{
if(x > 9) _print(x/10);
putchar(x%10 + '0');
}
void print(__int128 x)//输出
{
if(x < 0)
{
x = -x;
putchar('-');
}
_print(x);
}
int main()
{
__int128 a,b,p;
scan(a); scan(b); scan(p);
print(a%p*b%p%p);
return 0;
}