qsc oj 22 哗啦啦村的刁难(3)(随机数,神题)

哗啦啦村的刁难(3)

发布时间: 2017年2月28日 20:00   最后更新: 2017年2月28日 20:01   时间限制: 1000ms   内存限制: 128M

哗啦啦村作为喵哈哈村的对头,于是他们准备给喵哈哈村一个好看。

哗啦啦村的三号长老——大先生,就提出了以下问题:

现在这道题有两组数据,每组输入数据都是1,。

但是,第一组测试数据你需要输出1,第二组你需要输出2。

你怎么输出呢?

1

这道题只包含两组测试数据,第一组测试数据应该输出1,第二组你应该输出2.

 
1
1
 
1
2
题目链接:http://qscoj.cn/problem/22/
分析:

解法:卿学姐说OJ是并行哒,所以时间随机是不可行的,我们这里new一个东西,取地址是随机的

下面给出AC代码:

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 #include <math.h>
 5 #include <iostream>   // C++头文件,C++完全兼容C
 6 #include <algorithm>  // C++头文件,C++完全兼容C
 7 #include <time.h>
 8 #define fre  freopen("in.txt","r",stdin)   //以文件代替控制台输入,比赛时很常用,能缩短输入测试样例的时间
 9 #define INF 0x3f3f3f3f
10 #define inf 1e60
11 using namespace std;  // C++头文件,C++完全兼容C
12 const int maxn = 200;
13 int a[maxn];
14 int b[3];
15 int ans,n,k;
16 
17 int main()
18 {
19 
20     cin>>n;
21     char* x=new char;
22     int ans=(long)x;
23     printf("%d
",ans/10%2+1);
24 
25     return 0;
26 }
原文地址:https://www.cnblogs.com/ECJTUACM-873284962/p/6822826.html