結果
問題 | No.401 数字の渦巻き |
ユーザー |
![]() |
提出日時 | 2016-07-22 22:59:29 |
言語 | C++11 (gcc 13.3.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,280 bytes |
コンパイル時間 | 452 ms |
コンパイル使用メモリ | 66,512 KB |
最終ジャッジ日時 | 2024-11-14 19:47:38 |
合計ジャッジ時間 | 1,041 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:25:23: error: ‘acos’ was not declared in this scope 25 | constexpr double PI = acos(-1); | ^~~~
ソースコード
#include <iostream>#include <vector>#include <map>#include <set>#include <queue>#include <algorithm>#include <iomanip>#include <cassert>using namespace std;#define GET_ARG(a,b,c,F,...) F#define REP3(i,s,e) for (i = s; i <= e; i++)#define REP2(i,n) REP3 (i,0,(int)(n)-1)#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)#define RREP3(i,s,e) for (i = s; i >= e; i--)#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)#define DEBUG(x) cerr << #x ": " << x << endltypedef long long ll;constexpr int INF = 1e8;constexpr int MOD = 1e9+7;constexpr int ESP = 1e-9;constexpr double PI = acos(-1);int ans[30][30];int dxy[4] = {0,1,0,-1};int main(void) {int n;cin >> n;int x = 0, y = 0, dir = 0, num;REP (num,1,n*n) {ans[y][x] = num;int ny = y + dxy[dir];int nx = x + dxy[(dir+1)%4];if (nx < 0 || nx >= n || ny < 0 || ny >= n || ans[ny][nx] > 0) {dir = (dir + 1) % 4;ny = y + dxy[dir];nx = x + dxy[(dir+1)%4];}x = nx;y = ny;}REP (y,n) REP (x,n) {cout << setfill('0') << setw(3);cout << ans[y][x] << (x < n-1 ? ' ' : '\n');}return 0;}