社区讨论

听取WA声一片

P11229[CSP-J 2024] 小木棍参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@m63jho2l
此快照首次捕获于
2025/01/19 19:33
去年
此快照最后确认于
2025/11/04 11:16
4 个月前
查看原帖
Advertisement 1Advertisement 2
明月AC惊鹊,清风WA鸣蝉。明月AC惊鹊,清风WA鸣蝉。 80分里说测试点,听取WA声一片。80分里说测试点,听取WA声一片。 七八个AC外,两三点WA前。七八个AC外,两三点WA前。 旧时AC社林边,路转WA忽见。旧时AC社林边,路转WA忽见。如下
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int arr_WA[] = {9, 10};
  int ans = 100;
  cout << "1    2    3    4    5    6    7   8    9   10" << '\n';
  for (int i = 1; i <= 10; i++) {
    if (arr_WA[0] == i || arr_WA[1] == i) {
      cout << "TLE" << ' ';
      ans -= 10;
    }
    else cout << "AC" << ' ';
  }
  printf("\n%d", ans);
  return 0;
}

正文
CPP
#include <bits/stdc++.h>

using namespace std;

/*
1        n<20
2        n<50
3        n<1000&&n>=100&&n%7==0
4~5      n<100000&&n>=100&&n%7==0
6        n<1000&&n>=100&&n%7==1
7~8      n<100000&&n>=100&&n%7==1
9        n<1000
10       n<100000
*/

int f(int n) {
	int arr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	int sum = 0;
	while (n) {
		sum += arr[n % 10];
		n /= 10;
	}
	return sum;
}

int main() {
	int t;
	cin >> t; 
	for (int i = 1; i <= t; i++) {
		int n;
		cin >> n;
		if (n == 1) {
			cout << -1;
		} else if (n % 7 == 0) {
			for (int i = 1; i <= n / 7; i++) {
				cout << 8;
			}
		} else if (n % 7 == 1) {
			cout << 10;
			for (int i = 1; i <= n / 7 - 1; i++) {
				cout << 8;
			}
		} else {
			int i; 
			for (i = 1; f(i) != n; i++);
			cout << i;
		}
		cout << endl;
	}
	return 0;
}

回复

0 条回复,欢迎继续交流。

正在加载回复...