結果
問題 |
No.886 Direct
|
ユーザー |
![]() |
提出日時 | 2019-08-19 22:50:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,452 bytes |
コンパイル時間 | 1,730 ms |
コンパイル使用メモリ | 167,644 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-10-05 09:36:37 |
合計ジャッジ時間 | 7,016 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 TLE * 1 |
other | -- * 32 |
ソースコード
#include <bits/stdc++.h> #define MOD 1000000007 int ri() { int n; scanf("%d", &n); return n; } template<int mod> struct ModInt{ int x; ModInt():x(0){} ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){} ModInt &operator+=(const ModInt &p){ if((x+=p.x)>=mod)x-=mod; return *this; } ModInt &operator-=(const ModInt &p){ if((x+=mod-p.x)>=mod)x-=mod; return *this; } ModInt &operator*=(const ModInt &p){ x=(int)(1LL*x*p.x%mod); return *this; } ModInt &operator/=(const ModInt &p){ *this*=p.inverse(); return *this; } ModInt &operator^=(long long p){ ModInt res = 1; for (; p; p >>= 1) { if (p & 1) res *= *this; *this *= *this; } return *this = res; } ModInt operator-()const{return ModInt(-x);} ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;} ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;} ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;} ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;} ModInt operator^(long long p)const{return ModInt(*this)^=p;} bool operator==(const ModInt &p)const{return x==p.x;} bool operator!=(const ModInt &p)const{return x!=p.x;} explicit operator int() const { return x; } // added by QCFium ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium ModInt inverse()const{ int a=x,b=mod,u=1,v=0,t; while(b>0){ t=a/b; a-=t*b; std::swap(a,b); u-=t*v; std::swap(u,v); } return ModInt(u); } friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){ return os<<p.x; } friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){ long long x; is>>x; a=ModInt<mod>(x); return (is); } }; typedef ModInt<MOD> mint; int gcd(int x, int y) { x = std::abs(x); y = std::abs(y); while (x && y) { if (x > y) x %= y; else y %= x; } return x + y; } int main() { int h = ri(), w = ri(); int res = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { for (int k = 0; k < h; k++) { for (int l = 0; l < w; l++) { if (i == k && j == l) continue; if (gcd(k - i, l - j) == 1) res++; } } } } std::cout << res / 2 << std::endl; return 0; }