CF - 1130 E Wrong Answer

PS:换了一种方式 希望大家喜欢 2333

/**
code by: zstu wxk
time: 2019/03/01
Problem Link: http://codeforces.com/contest/1130/problem/E
solve:
如果构造的数列是 0 0 0 0 0 0 0 -1 + + + +(+代表大于0的数)
那么 find_answer = sum(+) * len_+
实际上的答案为 tot_len * [sum(+) - 1]
即: sum(+) * len_+ + k = tot_len * [sum(+) - 1]
接下来就是枚举tot_len就好了
**/
#include<bits/stdc++.h>
using namespace std;
#define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout);
#define LL long long
#define ULL unsigned LL
#define fi first
#define se second
#define pb push_back
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lch(x) tr[x].son[0]
#define rch(x) tr[x].son[1]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef pair<int,int> pll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL _INF = 0xc0c0c0c0c0c0c0c0;
const LL mod = (int)1e9+;
const int N = 1e5 + ;
int n, k, t1, t2;
int a[N];
bool check(int x){
for(int i = ; i * i <= x; ++i){
if(x % i == ){
t1 = i, t2 = x/i;
t1 = n - t1;
if(t1 < n - && t2 < 1e6 * t1)
return true;
}
}
return false;
}
void Ac(){
n = ;
memset(a, , sizeof a);
for(n = ; n >= ; --n){
if(check(n+k)){
for(int i = ; i <= t1; ++i){
if(t2 >= 1e6){
a[i] = 1e6;
t2 -= 1e6;
}
else{
a[i] = t2;
t2 = ;
}
}
a[t1+] = -;
printf("%d\n", n);
reverse(a+, a++n);
for(int i = ; i <= n; ++i){
printf("%d ", a[i]);
}
break;
}
}
}
int main(){
while(~scanf("%d", &k)){
Ac();
}
return ;
}
上一篇:Educational Codeforces Round 10 B. z-sort 构造


下一篇:Codeforces 1368E - Ski Accidents(构造+思维)