結果

問題 No.2057 Ising Model
ユーザー Nzt3
提出日時 2022-08-26 22:15:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 317 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 191,600 KB
最終ジャッジ日時 2025-01-31 05:01:10
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long N,A,B;
  cin>>N>>A>>B;
  long long ans=A*(N-1)-B*N;
  if(A*2>B){
    ans-=A*4*((N-1)/2);
    ans+=B*2*((N-1)/2);
    if(N%2==0&&A>B){
      ans-=A*2;
      ans+=B*2;
    }
  }
  cout<<ans<<'\n';
}
0