結果
| 問題 |
No.2057 Ising Model
|
| コンテスト | |
| ユーザー |
maitakeshimeji6
|
| 提出日時 | 2022-08-27 00:28:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 640 bytes |
| コンパイル時間 | 798 ms |
| コンパイル使用メモリ | 91,664 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 01:12:45 |
| 合計ジャッジ時間 | 1,954 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstdio>
#include <iomanip>
#include <list>
#define PI 3.14159265358979323846
#define mod 1000000007
#define pow9 1000000000
#define INF (1 << 30)
using namespace std;
int main() {
long long n, a, b;
cin >> n >> a >> b;
long long ans1, ans2;
long long ans3 = INF;
if (n % 2 == 0) {
ans1 = a * (-(n - 1));
ans3 = a *(-(n - 3)) - 2 * b;
}
else {
ans1 = a * (-(n - 1)) - b;
}
ans2 = a * (n - 1) - b * n;
cout << min(ans1,min( ans2, ans3)) << endl;
}
maitakeshimeji6