結果
問題 |
No.3179 3 time mod
|
ユーザー |
![]() |
提出日時 | 2025-06-28 03:35:29 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 12,478 ms |
コンパイル使用メモリ | 240,548 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-28 03:35:43 |
合計ジャッジ時間 | 14,092 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 42 |
ソースコード
package main import . "fmt" import . "math/big" func main() { var n,p,q,r,a,b,c int64 Scan(&n,&p,&q,&r,&a,&b,&c) ans := solve(n,p,q,r,a,b,c) Println(ans) } func solve(n,p,q,r,a,b,c int64) (ans int64) { pqr := p*q*r X, Y, Z := new(Int), new(Int), new(Int) new(Int).GCD(nil, X, NewInt(p), NewInt(pqr/p)) new(Int).GCD(nil, Y, NewInt(q), NewInt(pqr/q)) new(Int).GCD(nil, Z, NewInt(r), NewInt(pqr/r)) X.Mul(X, NewInt(pqr/p)).Mul(X, NewInt(a)) Y.Mul(Y, NewInt(pqr/q)).Mul(Y, NewInt(b)) Z.Mul(Z, NewInt(pqr/r)).Mul(Z, NewInt(c)) xyz := new(Int).Add(X, new(Int).Add(Y, Z)) m := new(Int).Mod(xyz, NewInt(pqr)).Int64() ans = n / pqr if n % pqr >= m { ans++ } return }