2 条题解
-
1
这里提供一个不用龟速乘的方法,用 __int128 写。
#include<bits/stdc++.h> #define int long long #define I_love_ch ios::sync_with_stdio(0) #define China cin.tie(0) #define France cout.tie(0) #define ch_France return 0 using namespace std; void read(__int128& x){ int f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } x*=f; } void print(__int128 x){ if(x==0){ cout<<"0\n"; return; } bool f=0; if(x<0){ f=1; x=-x; } string s; while(x){ s.push_back(x%10+'0'); x/=10; } if(f) cout<<"-"; reverse(s.begin(),s.end()); cout<<s<<"\n"; } __int128 a,b,p; signed main(){ I_love_ch; China; France; read(a); read(b); read(p); int ans=((a%p)*(b%p))%p; print(ans); ch_France; }
信息
- ID
- 823
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- (无)
- 递交数
- 19
- 已通过
- 10
- 上传者