跳到正文

个人记录

如何在极端条件下 AC P1001?

Hicka_Stone约 1 分钟
原文

这是 2026年2月26日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年2月13日
收录
2026年2月26日
更新
2026年11月18日
篇幅
约 1 分钟
获赞
1

版本

  1. v2当前
  2. v1

1.无限制

十分简单,只需输入 a、ba、b 后输出 a+ba+b 即可。

C++
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a+b);
    return 0;
}

2.‘+’被抠掉了

简单,把+换成两个-就行了

C++
#include <cstdio>
using namespace std;
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a-(-b));
    return 0;
}

(注意头文件也不能用万能头)

3.‘-’ ‘*’ ‘/’ ‘^’也被抠了

不要慌,别忘了我们还有移位!!

C++
#include<cstdio>
#include<cmath>
#define int long long
using namespace std;
signed main()
{
	int a,b,cnt=1;
	scanf("%lld%lld",&a,&b);
	cnt=cnt<<a;
	cnt=cnt<<b;
	printf("%lld",(int)log2(cnt));
	return 0;
}

(a、ba、b 需要小于32)

后记

如果数据较小(如 a,b≤109a,b≤10^9 )其实可以打表 : )