結果

問題 No.3152 neither multiple of A nor B
ユーザー ゼット
提出日時 2025-05-20 21:21:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 76,460 KB
最終ジャッジ日時 2025-05-20 21:21:36
合計ジャッジ時間 4,183 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

u=[1]*10**6
u2=[1]*(10**6)
mod=998244353
for i in range(1,10**6):
  u[i]=u[i-1]*i
  u[i]%=mod
u2[10**6-1]=pow(u[10**6-1],-1,mod)
for i in range(10**6-2,0,-1):
  u2[i]=u2[i+1]*(i+1)
  u2[i]%=mod
def ncm(x,y):
  if y>x or y<0:
    return 0
  ans=u[x]*u2[y]
  ans%=mod
  ans*=u2[x-y]
  ans%=mod
  return ans
N,A,B=map(int,input().split())
result=N
from math import gcd
x=gcd(A,B)
M=A*B//x
result-=N//A
result-=N//B
result+=N//M
print(result)
0