CSP的读入到底怎么读?
  • 板块学术版
  • 楼主To_Carpe_Diem
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/10/27 08:44
  • 上次更新2024/10/27 09:51:36
查看原帖
CSP的读入到底怎么读?
837396
To_Carpe_Diem楼主2024/10/27 08:44
  1. 关闭同步流
  2. scanf
  3. read

这几个相互之间有没有影响?

最后,如果11 &\& 33 同时用可以吗?代码如下:

#include<iostream>
using namespace std;

int read(){
	int x = 0,w = 1;
	char c = getchar();
	while(c < '0' || c > '9'){
		if(c == '-') w = -1;
		c = getchar();
	}
	while(c <= '9' && c >= '0'){
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * w;
}

int T;
int n;
const int MAXN = 15000;
string s[MAXN];
int ans[10] = {0,-1,1,7,4,2,6,8,10};

int main(){
freopen("sticks.in","r",stdin);
freopen("sticks.out","w",stdout);
	cin.tie(0) -> ios::sync_with_stdio(0);
	cout.tie(0);
	for(int i = 1;i <= MAXN - 1;i ++){
		s[i] = s[i - 1] + '8';
	}
	T = read();
	while(T --){
		n = read();
		if(n <= 8){
			cout << ans[n] << '\n';
		}
		else if(n % 7 == 0){
			cout << s[n / 7] << '\n';
		}
		else if(n % 7 == 1){
			cout << 10;
			n -= 8;
			cout << s[n / 7] << '\n';
		}
		else if(n % 7 == 2){
			cout << 1; 
			n -= 2;
			cout << s[n / 7] << '\n';
		}
		else if(n % 7 == 3){
			if(n == 10){
				cout << 22 << '\n';
			}
			else{
				cout << 200; 
				n -= 17;
				cout << s[n / 7] << '\n';
			}
		}
		else if(n % 7 == 4){
			cout << 20; 
			n -= 11;
			cout << s[n / 7] << '\n';
		}
		else if(n % 7 == 5){
			cout << 2; 
			n -= 5;
			cout << s[n / 7] << '\n';
		}
		else if(n % 7 == 6){
			cout << 6; 
			n -= 6;
			cout << s[n / 7] << '\n';
		}
	}
	return 0;
}
2024/10/27 08:44
加载中...