結果
| 問題 | 
                            No.373 かけ算と割った余り
                             | 
                    
| コンテスト | |
| ユーザー | 
                            👑  | 
                    
| 提出日時 | 2019-03-30 19:34:19 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 459 bytes | 
| コンパイル時間 | 537 ms | 
| コンパイル使用メモリ | 53,980 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-16 18:40:16 | 
| 合計ジャッジ時間 | 1,061 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 2 WA * 3 | 
ソースコード
#include <iostream>
#include <cstdlib>
long modinv(long src, long mod)
{
    long num = mod - 2;
    long res = 1;
    while(0 < num){
        if(num % 2 == 1){
            res = (res * src) % mod;
            num--;
        }
        src = (src * src) % mod;
        num /= 2;
    }
    return res;
}
int main()
{
    long a, b, c, d;
    std::cin >> a >> b >> c >> d;
    a *= b; a %= d;
    a *= modinv(c, d); a %= d;
    std::cout << a << std::endl;
}