51Nod-1804-小C的多边形
来源:互联网 发布:玩客云京东抢购软件 编辑:程序博客网 时间:2024/05/19 13:29
ACM模版
描述
题解
这个题是一个构造体,只要发现了其中构造的规律即可。
一开始我画了半天
注意,由于这个问题需要用到大量的输出,所以记住开输出外挂哦……
代码
#include <cstdio>#include <iostream>using namespace std;const int MAXN = 1e6 + 10;const int MAXM = 10;const int MAX_BUFF = 1 << 24;int A[MAXN];char s[MAX_BUFF];char tmp[MAXM];void intToChar(int &pos, int a){ int cnt = 0; while (a) { tmp[cnt++] = a % 10; a /= 10; } while (cnt != 0) { s[pos++] = tmp[--cnt] + '0'; }}int main(){ int n; cin >> n; n--; if (n % 2 == 0) { cout << 0 << '\n'; return 0; } int k = 1, num = n; while (1) { A[k] = num--; if (k == n - 1) { break; } k = (k + 2); if (k >= n) { k -= n; } } int pos = 0; for (int i = 1; i < n; i++) { intToChar(pos, i); s[pos++] = ' '; } intToChar(pos, n); s[pos++] = '\0'; puts(s); pos = 0; for (int i = 0; i < n - 1; i++) { intToChar(pos, A[i]); s[pos++] = ' '; } intToChar(pos, A[n - 1]); s[pos++] = '\0'; puts(s); return 0;}
0 0
- 【51Nod】1804 小C的多边形
- 51Nod-1804-小C的多边形
- 51nod 1804 小C的多边形
- 51nod 1804 小C的多边形
- 51nod 1804 小C的多边形(规律)
- 51nod 1804 小C的多边形(贪心)
- 51 nod 1804 小C的多边形(贪心)
- 51nod小c的多边形(找规律(构造))
- 小C的多边形
- 51Nod 1831 小C的游戏
- 51Nod-1831-小C的游戏
- 51nod 1831 小C的游戏
- 51nod-1831 小C的游戏
- 51nod 欢乐手速场C 开心的小Q
- [51Nod 1816] 小C的二分图 口胡
- 【51nod 1816】 小C的二分图 口胡题解
- 51nod 1456:小K的技术
- [51nod 1471]小S的兴趣
- python变量笔记
- 管道的四种读写情况
- 【C++】优先级队列的模拟实现
- 错误:在自己制作的dll库时,出现错误"*100ud.dll"丢失
- 数据库TPCC benchmark测试工具对比
- 51Nod-1804-小C的多边形
- oracle帐号scott被锁定如何解锁
- Ajax概念介绍
- 共享内存
- Oracle
- 错误:在使用win32应用程序时,一开始运行就中断
- 1031. Hello World for U (20)
- 集成iOS支付宝支付
- Hibernate对象状态管理