跳到正文

题解

题解:P14117 [SCCPC 2021] Chuanpai

Quiet_Little_Girl约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年10月2日
收录
2026年5月28日
更新
2026年11月14日
篇幅
约 1 分钟
题目
P14117

版本

  1. v1当前

枚举即可

思路

枚举所有可能的 (x,y) 组合,并统计满足条件 x+y=k 的数量。

代码

C++
#include<bits/stdc++.h>
using namespace std;
int t,k;
int main(){
	cin>>t;
	while(t--){
		int cnt=0;
		cin>>k;
		for(int x=1;x<=6;x++)
			for(int y=x;y<=6;y++)//1≤x≤y≤6
				if(x+y==k) cnt++;
		cout<<cnt<<endl;
	}
	return 0;
}
原文