信友队汪老师
(汪老师)
1
今天是8月21号,金同学参加了军训
。
带班的教官不仅体能强悍
,而且还了解编程
。
他带大家玩了一个游戏,叫作:INT爆炸!
教官每次会说出 3 个小于 2000 的正整数,
你要快速地判断出这 3 个数相乘是否会超出 2^31-1
。
如果超出的话就要回答:爆炸!,否则回答:安全。
你觉得这个任务怎么样?
#include <ctime>
#include <cstdlib>
#include <climits>
#include <string>
#include <iostream>
using namespace std;
int main ()
{
string s[2] = {"爆炸!", "安全。"};
srand(time(NULL));
int a = rand() % 1223 + 777;
int b = rand() % 1223 + 777;
int c = rand() % 1223 + 777;
cout << a << " " << b << " " << c << endl;
cout << s[/*判断三数相乘是否爆炸*/] << endl;
return 0;
}
2 个赞
崩坏星穹铁道
(崩坏星穹铁道)
2
#include <ctime>
#include <cstdlib>
#include <climits>
#include <string>
#include <iostream>
using namespace std;
int main ()
{
string s[2] = {"爆炸!", "安全。"};
srand(time(NULL));
int a = rand() % 1223 + 777;
int b = rand() % 1223 + 777;
int c = rand() % 1223 + 777;
cout << a << " " << b << " " << c << endl;
cout << s[((int)(a*b*c)/(int)(a*b)==c)?1:0] << endl;
return 0;
}

2 个赞
点赞姐
(点赞姐[赞])
3
(int)(a*b*c)/(int)(a*b)==c
这判断了什么
2 个赞
崩坏星穹铁道
(崩坏星穹铁道)
4
int不是会爆吗,如果能除得正确的结果就是原数,否则的话就是
了
2 个赞
胡瑜辰
(胡瑜辰)
8
来点强转暴力!
#include <ctime>
#include <cstdlib>
#include <climits>
#include <string>
#include <iostream>
using namespace std;
int main ()
{
string s[2] = {"爆炸!", "安全。"};
srand(time(NULL));
int a = rand() % 1223 + 777;
int b = rand() % 1223 + 777;
int c = rand() % 1223 + 777;
cout << a << " " << b << " " << c << endl;
cout << s[(long long)a*(long long)b*(long long)c <= (1ll<<31ll)-1ll] << endl;
return 0;
}
不知道有没有bug,如果找得到的话告诉我 
3 个赞
信友队学生
(信友队学生)
16
每日一练3 最强大脑
lester参加最强大脑比赛,比赛内容是默记对一个序列(初始时为空)的操作 操作1:Q L,表示需要写下当前数列中末L个数中的最大值(保证L不超过序列当前长度) 操作2:A n,表示在序列尾部增加一个数,值为(n+t)%p,t表示上一次Q操作的答案(如之前无Q操作,t=0),p是一个常数 lester靠心算就能完成这些简单的操作,你就不行了,所以你只能写代码实现
你觉得这个任务怎么样?