题目链接:Codeforces 400A Inna and Choose Options
题目大意:给出一个字符串,长度为12,选出两个数,a和b,要求a*b = 12,然后将字符串分出长度为b的a份,然后叠放在一起,形成一个有a行b列的矩阵,如果有某一列上的字符都是‘X’,该组a,b即为满足要求。问说有多少组ab满足,并输出满足的ab组合。
解题思路:暴力水题,题意知道了就很简单。
#include <stdio.h>
#include <string.h>
const int N = 15;
const int d[N] = {1, 2, 3, 4, 6, 12};
char str[N];
bool judge(int u) {
for (int i = 0; i < u; i++) {
bool flag = true;
for (int j = i; j < 12; j += u) if (str[j] != 'X') {
flag = false; break;
}
if (flag) return true;
}
return false;
}
int main () {
int cas;
scanf("%d", &cas);
while (cas--) {
scanf("%s", str);
int ans = 0, v[N];
memset(v, 0, sizeof(v));
for (int i = 0; i < 6; i++) if (judge(12/d[i])) {
v[i] = 1;
ans++;
}
printf("%d", ans);
for (int i = 0; i < 6; i++) if (v[i]) {
printf(" %dx%d", d[i], 12/d[i]);
}
printf("\n");
}
return 0;
}
分享到:
相关推荐
Codeforces 题库 101-200 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
Codeforces 题库 001-100 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
codeforces编程网站预测分数插件
使用于Google Chrome的Codeforces Enhancer 1.1.2插件安装包。 版本:codeforces enhancer 1.1.2 使用浏览器:Google Chrome
暴枚最长桌脚的长度$l$,然后长度比$l$长的桌脚全部都要砍掉长度比$l$短的桌脚选择代价前$k$小的砍掉用线段树维护;示例程序 :typedef long l
Codeforces 185A - Plant 全测试点49个
Codeforces 1105B - Zuhair and Strings 测试点37个(全)
codeforces 19 E Fairy 一道比较难的题目的解题报告 推荐阅读
Codeforces global round 10 codes
Codeforces round 678 division 2 codes
Some of the Codeforces problems codes
Codeforces round 678 D2_Codeforces_源码
一个Codeforces、牛客竞赛、AtCoder平台的编程竞赛查询插件,ACMer必备.zip
打codeforces的神器
codeforces-js Codeforces JS
lucifer1004大佬的博客cf上分攻略故里大佬的githubcf思维题刷题数:44- (1421)codeforces 676 div2 A,B done
Codeforces Round #723 (Div. 2).md
使用 C# + WPF 开发 --- 还在发愁打了那么多场比赛都没有进入首页么? 还在为了前 5 的 hacker 名额阅读千份代码么? 是的,你没有看错! 这是一个 Edu & Div.3 轮 Open hacking 错误代码自动查找器!...
Codeforces 题库 201-294 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
PDF-CodeForces问题 PDF文件中的CodeForces问题 利用CodeForces提取在这个库中的文件 ,文件夹名代表来自CodeForces网址contests`的ID,每个文件夹包含比赛的问题。 有关CodeForces竞赛的疯狂事实 CodeForces上有937...