0
点赞
收藏
分享

微信扫一扫

A. Number of Apartments(暴力出奇迹) Educational Codeforces Round 96 (Rated for Div. 2)

伢赞 2022-06-24 阅读 18

原题链接: ​​https://codeforces.com/contest/1430/problem/A​​

A. Number of Apartments(暴力出奇迹)  Educational Codeforces Round 96 (Rated for Div. 2)_#define
测试样例

input
4
30
67
4
14
output
2 2 2
7 5 3
-1
0 0 2

题意: 在一栋建筑中可能有A. Number of Apartments(暴力出奇迹)  Educational Codeforces Round 96 (Rated for Div. 2)_i++_02个窗户,A. Number of Apartments(暴力出奇迹)  Educational Codeforces Round 96 (Rated for Div. 2)_ios_03个窗户,A. Number of Apartments(暴力出奇迹)  Educational Codeforces Round 96 (Rated for Div. 2)_ios_04个窗户的公寓。现在给出窗户数,要你输出一个可能的公寓数量。

解题思路: 由于A. Number of Apartments(暴力出奇迹)  Educational Codeforces Round 96 (Rated for Div. 2)_#define_05很小,直接暴力枚举判断就行,水题。

AC代码

/*

*
*/
#include<bits/stdc++.h> //POJ不支持

#define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量,a为初始值,n为界限值,递增
#define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量, a为初始值,n为界限值,递减。
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define mp make_pair

using namespace std;

const int inf = 0x3f3f3f3f;//无穷大
const int maxn = 1e5;//最大值。
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
//*******************************分割线,以上为自定义代码模板***************************************//

int t,n;
int main(){
//freopen("in.txt", "r", stdin);//提交的时候要注释掉
IOS;
while(cin>>t){
while(t--){
cin>>n;
bool flag=false;
for(int i=0;i<=n/3;i++){
for(int j=0;j<=n/5;j++){
for(int q=0;q<=n/7;q++){
if(i*3+j*5+q*7==n){
flag=true;
cout<<i<<" "<<j<<" "<<q<<endl;
break;
}
}
if(flag)break;
}
if(flag)break;
}
if(!flag){
cout<<-1<<endl;
}
}
}
return 0;
}


举报

相关推荐

0 条评论