Gym - 102035L

Gym - 102035L

http://codeforces.com/gym/102035/problem/L

https://vjudge.net/contest/278159#problem/L

codeforce 

1.随机化生成数组,因为题目要求生成1000个数所以可以每次生成1个数判断与前面有没有矛盾,一开此还想着每次生成一个数接着前面,可是忘记考虑生成的数也有可能与前面矛盾,然后疯狂wa,以后记住遇到这种题先用暴力随机化测试时间,数据量小且可行,以此记住随机化方法

2.当 这个数很大时重复的概率也会大大减少,大佬做的,注意范围

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll mod = 1e9;
int main()
{
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)cout<<mod-i<<" ";
        cout<<endl;
}

猜你喜欢

转载自blog.csdn.net/qq_42193011/article/details/86378137