結果

問題 No.886 Direct
ユーザー beetbeet
提出日時 2019-09-14 06:55:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,152 bytes
コンパイル時間 1,959 ms
コンパイル使用メモリ 200,800 KB
実行使用メモリ 125,768 KB
最終ジャッジ日時 2023-09-18 14:34:20
合計ジャッジ時間 100,410 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,265 ms
125,768 KB
testcase_01 AC 2,268 ms
125,548 KB
testcase_02 AC 2,280 ms
125,476 KB
testcase_03 AC 2,310 ms
125,616 KB
testcase_04 AC 2,275 ms
125,484 KB
testcase_05 AC 2,257 ms
125,612 KB
testcase_06 AC 2,217 ms
125,564 KB
testcase_07 AC 2,217 ms
125,492 KB
testcase_08 AC 2,246 ms
125,484 KB
testcase_09 AC 2,230 ms
125,600 KB
testcase_10 AC 2,265 ms
125,496 KB
testcase_11 AC 2,282 ms
125,544 KB
testcase_12 AC 2,286 ms
125,476 KB
testcase_13 AC 2,264 ms
125,664 KB
testcase_14 AC 2,275 ms
125,668 KB
testcase_15 AC 2,259 ms
125,472 KB
testcase_16 AC 2,389 ms
125,496 KB
testcase_17 AC 2,390 ms
125,768 KB
testcase_18 AC 2,297 ms
125,480 KB
testcase_19 AC 2,257 ms
125,552 KB
testcase_20 AC 2,268 ms
125,540 KB
testcase_21 AC 2,294 ms
125,552 KB
testcase_22 AC 2,266 ms
125,596 KB
testcase_23 RE -
testcase_24 WA -
testcase_25 AC 2,298 ms
125,484 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
const int MAX = 1e6+100;
vector<int> D[MAX];
using M = Mint<int>;
M ys[MAX]={},xs[MAX]={};

signed main(){
  for(int i=1;i<MAX;i++)
    for(int j=i+i;j<MAX;j+=i)
      D[j].emplace_back(i);

  int h,w;
  cin>>h>>w;
  for(int i=1;i<h;i++) ys[i]=h-i;
  for(int j=1;j<w;j++) xs[j]=w-j;

  for(int x=2;x<MAX;x++){
    for(int y:D[x]){
      ys[y]+=ys[x];
      xs[y]+=xs[x];
    }
  }

  for(int i=0;i<MAX;i++) ys[i]*=xs[i];

  for(int x=MAX-1;x>=2;x--){
    for(int y:D[x]){
      ys[y]-=ys[x];
      xs[y]-=xs[x];
    }
  }

  M ans{0};
  ans+=ys[1]*M(2);
  ans+=M(h-1)*M(w);
  ans+=M(h)*M(w-1);

  cout<<ans<<endl;
  return 0;
}
0