結果

問題 No.1756 Rider's Triangle
ユーザー monnumonnu
提出日時 2021-11-20 16:38:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 636 bytes
コンパイル時間 3,940 ms
コンパイル使用メモリ 227,184 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-02 11:48:57
合計ジャッジ時間 11,118 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 152 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000000000000
#define MOD 998244353
#define MAX 1000000

int main(){
  ll a,b,N;
  cin>>a>>b>>N;
  if(a==b||a==0||b==0){
    cout<<0<<'\n';
    return 0;
  }
  ll x1=a;
  ll y1=b;
  ll x2,y2;
  while(true){
    x2=x1;
    y2=y1;
    while(y2*b>a*x2){
      x2+=b;
      y2-=a;
    }
    if(y2*b==a*x2){
      break;
    }
    x1+=a;
    y1+=b;
  }

  ll X=x2;
  ll Y=y1;
  ll ans=(max<ll>(0,N-X)%MOD)*(max<ll>(0,N-Y)%MOD)%MOD;
  ans*=8;
  ans%=MOD;
  cout<<ans<<'\n';

}
0