結果
| 問題 |
No.666 1000000007で割るだけ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-07 22:35:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 400 bytes |
| コンパイル時間 | 1,902 ms |
| コンパイル使用メモリ | 192,124 KB |
| 最終ジャッジ日時 | 2025-01-21 08:28:20 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d%d",&A,&B);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
//A*B(mod m)を出力する
int mul(int A,int B,int mod)
{
if(A<B)
{
std::swap(A,B);
}
int res=0,now=A;
while(B)
{
if(B&1)
{
res+=now;
res-=(res<mod)?0:mod;
}
B>>=1;
now<<=1;
now-=(now<mod)?0:mod;
}
return res;
}
int main()
{
int A,B,mod=1000000007;
scanf("%d%d",&A,&B);
printf("%d\n",mul(A,B,mod));
return 0;
}