Codeforces899C Dividing the numbers(数论)
http://codeforces.com/problemset/problem/899/C
tot为奇数时,绝对差为1;tot为偶数时,绝对差为0。
难点在于如何输出。
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cstdlib> 6 #include<cmath> 7 #include<vector> 8 #include<stack> 9 #include<queue> 10 #define lson l, m, rt<<1 11 #define rson m+1, r, rt<<1|1 12 #define IO ios::sync_with_stdio(false);cin.tie(0); 13 #define INF 0x3f3f3f3f 14 #define MAXN 500010 15 const int MOD=1e9+7; 16 typedef long long ll; 17 using namespace std; 18 ll n; 19 int main() 20 { 21 while(cin >> n){ 22 ll tot = (1+n)*n/2; 23 if(tot&1){ 24 cout << "1" << endl; 25 cout << n/2 << " "; 26 } 27 else{ 28 cout << "0" << endl; 29 cout << n/2 << " "; 30 } 31 for(int i = n, j = 0; i > 1; i -= 2, j = !j){ 32 cout << i-j << " " ; 33 } 34 cout << endl; 35 } 36 return 0; 37 }