結果
問題 |
No.3260 岩井スターグラフ
|
ユーザー |
![]() |
提出日時 | 2025-09-07 16:33:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 411 ms |
コンパイル使用メモリ | 43,892 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-07 16:34:02 |
合計ジャッジ時間 | 5,820 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d%d%d", &x, &y, &n); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:36:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | scanf("%lld%lld", &u, &v); | ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3260.cc: No.3260 蟯ゥ莠輔せ繧ソ繝シ繧ー繝ゥ繝・- yukicoder */ #include<cstdio> #include<algorithm> #include<utility> using namespace std; /* constant */ /* typedef */ using ll = long long; using pii = pair<int,int>; /* global variables */ /* subroutines */ pii p2ij(ll p, int y) { if (p == 0) return {0, 0}; return {(p - 1) / y, (p - 1) % y + 1}; } /* main */ int main() { int x, y, n; scanf("%d%d%d", &x, &y, &n); while (n--) { ll u, v; scanf("%lld%lld", &u, &v); if (u > v) swap(u, v); auto [ui, uj] = p2ij(u, y); auto [vi, vj] = p2ij(v, y); printf("%d\n", (ui == vi) ? vj - uj : uj + vj); } return 0; }