链接:https://www.nowcoder.com/acm/contest/132/A
来源:牛客网
有趣的题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
给6个火柴棍,问能不能拼成“熊”或者“象”“熊”:4根棍子长度一样,另外2根棍子长度不一样“象”:4根棍子长度一样,另外2根棍子长度一样。
如果可以拼出熊,输出“Bear”如果可以拼出象,输出“Elephant”
如果都不可以拼出,输出“Hernia”
输入描述:
一行六个数表示每个火柴棍的长度
输出描述:
输出一行一个字符串表示答案
备注:
火柴棍长度在[1,9]内
1 #include <iostream> 2 3 using namespace std; 4 5 int a[10]; 6 int main(){ 7 int n =6; 8 while(n--){ 9 int x; 10 cin>>x; 11 a[x]++; 12 } 13 bool flag = false; 14 for(int i=1;i<=9;i++){ 15 if(a[i]>=4){ 16 a[i] = a[i]-4; 17 flag = true; 18 } 19 } 20 if(flag){ 21 int x = 0; 22 for(int i=0;i<=9;i++){ 23 if(a[i]) 24 x++; 25 } 26 if(x==2) 27 cout<<"Bear"<<endl; 28 else{ 29 cout<<"Elephant"<<endl; 30 } 31 }else{ 32 cout<<"Hernia"<<endl; 33 } 34 35 36 return 0; 37 }
链接:https://www.nowcoder.com/acm/contest/132/B
来源:牛客网
送分题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
1 #include <iostream> 2 #define ll long long int 3 using namespace std; 4 5 int main(){ 6 ll a,b,c; 7 cin>>a>>b>>c; 8 ll an,bn,cn,dn; 9 an = a+b*c; 10 bn = a*(b+c); 11 cn = a*b*c; 12 dn = (a+b)*c; 13 14 an = max(an,bn); 15 an = max(an,cn); 16 an = max(an,dn); 17 an = max(an,a+b+c); 18 cout<<an<<endl; 19 20 return 0; 21 }
链接:https://www.nowcoder.com/acm/contest/132/C
来源:牛客网
简单瞎搞题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
一共有 n个数,第 i 个数是 xi
xi 可以取 [li , ri] 中任意的一个值。
设 ,求 S 种类数。输入描述:
第一行一个数 n。
然后 n 行,每行两个数表示 li,ri。
输出描述:
输出一行一个数表示答案。
备注:
1 ≤ n , li , ri ≤ 100
bitset用了位运算可以好的解决这种问题.
还没怎么看懂,,,,,,,,,.
1 #include <iostream> 2 #include <bitset> 3 4 using namespace std; 5 bitset<1000005> ans , t; 6 int n; 7 int main(){ 8 cin>>n; 9 ans[0] = 1; 10 for(int i=0;i<n;i++){ 11 int x,y; 12 cin>>x>>y; 13 t.reset(); 14 for(int j = x;j<=y;j++){ 15 t |= (ans<<j*j); 16 } 17 ans = t; 18 } 19 cout<<ans.count()<<endl; 20 return 0; 21 }