3 August
P1013 进制位
结论:加法必为 \(n-1\) 进制;\({(n-1)}^1\) 位必为数字 1;\(0+0=0\)。
模拟、字符串。
#include <cstdio>
#include <map>
#include <cstring>
using namespace std;
int n, num[11], id[11], tab[11][11];
map<char, int> p;
map<int, char> q;
char s[3];
bool check() {
for (int i=1; i<n; ++i) for (int j=1; j<n; ++j)
if (tab[i][j]!=id[(num[i]+num[j])%(n-1)]) return false;
return true;
}
int main() {
memset(num, -1, sizeof num);
scanf("%d", &n); scanf("%s", s);
for (int i=1; i<n; ++i) {
scanf("%s", s); p[s[0]]=i, q[i]=s[0];
}
for (int i=1; i<n; ++i) {
scanf("%s", s); int k=p[s[0]];
for (int j=1; j<n; ++j) {
scanf("%s", s);
if (s[1]) num[id[1]=p[s[0]]]=1, tab[k][j]=p[s[1]];
else tab[k][j]=p[s[0]];
}
}
for (int i=1; i<n; ++i) if (tab[i][i]==i) num[id[0]=i]=0;
int k=1;
while (tab[id[1]][id[k]]!=id[0]) {
num[id[k+1]=tab[id[1]][id[k]]]=k+1; ++k;
if (k>n-1) break;
}
if (check()) {
for (int i=1; i<n; ++i) printf("%c=%d ", q[i], num[i]);
printf("\n%d\n", n-1);
} else printf("ERROR!\n");
return 0;
}
3 August的更多相关文章
- Monthly Income Report – August 2016
原文链接:https://marcoschwartz.com/monthly-income-report-august-2016/ Every month, I publish a report of ...
- [ZZ]Sign Up for the First-Ever Appium Roadshow on August 20th in New York City
http://sauceio.com/index.php/2014/07/appium-roadshow-nyc/?utm_source=feedly&utm_reader=feedly&am ...
- 浙大月赛ZOJ Monthly, August 2014
Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...
- [转载]ECMA-262 6th Edition / Draft August 24, 2014 Draft ECMAScript Language Specification
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-23.4 Draft Report Errors and Issues at: htt ...
- 135 - ZOJ Monthly, August 2014
135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][ ...
- git -remote: Support for password authentication was removed on August 13, 2021
克隆代码时,报错: Support for password authentication was removed on August 13, 2021. Please use a personal ...
- August 31st 2016 Week 36th Tuesday
A friend without faults will never be found. 没有缺点的朋友是永远找不到的. You can't find a friends without faults ...
- August 30th 2016 Week 36th Tuesday
If you keep on believing, the dreams that you wish will come true. 如果你坚定信念,就能梦想成真. I always believe ...
- August 29th 2016 Week 36th Monday
Every has the capital to dream. 每个人都有做梦的本钱. Your vision, our mission. That is an advertisment of UMo ...
- August 28th 2016 Week 36th Sunday
What doesn't kill you makes you stronger. 那些没有彻底击败你的东西只会让你更强大. Where there is life, there is hope, a ...
随机推荐
- delphi 之 get post
http://www.cnblogs.com/ccqin/archive/2012/08/22/2650348.html delphi 之 get post 没测试过这个 var Source: TM ...
- Delphi中Tlist实例
http://blog.163.com/jiandande3218@126/blog/static/74728469201132721428194/ Delphi中Tlist实例 2011-04-27 ...
- EL表达式(二)运算符
运算符"."和"[]": "."能做的"[]"也能做,"[]"能做的"."不一定 ...
- webStom常用快捷键备忘
Ctrl+W 选中代码,连续按会有其他效果 Ctrl+/ 或 Ctrl+Shift+/ 注释(// 或者/…/ ) Ctrl+X 删除行Ctrl+D 复制行 ctrl+shift+ 箭头 上下移动块代 ...
- [Bzoj3224][Tyvj1728] 普通平衡树(splay/无旋Treap)
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=3224 平衡树入门题,学习学习. splay(学习yyb巨佬) #include<b ...
- kafaka环境搭建
激动无比,终于成功搭建了一套集群的kafka,记录下我的搭建步骤,供大家参考,如有不对,请指正: 1.集群搭建 首先搭建一个一主三从(或一主两从)的集群, 2.配置jdk环境 需要是jdk8的包 我的 ...
- VS Code的使用
之前一直使用的是WebStorm来学习web前端开发,最近开始使用VSCode,很多方面和WebStorm不一样,需要一段时间适应,以下是我初次使用VSCode进行web前端开发学习所遇到的一些问题以 ...
- elasticsearch 基础 —— 请求体查询
请求体查询 简易 查询 -query-string search- 对于用命令行进行即席查询(ad-hoc)是非常有用的. 然而,为了充分利用查询的强大功能,你应该使用 请求体 search API, ...
- XILINX FPGA 开发板 XC3S250E 核心板 学习板+12模块
北京太速科技有限公司为广大合作单位特设海外代购业务,主要包括各类板卡.相机.传感器.仪器仪表.专用芯片等.代购业务仅收取基本的手续费. 北京太速科技有限公司在线客服:QQ:448468544 淘宝网站 ...
- go语言从例子开始之Example38.排序
Go 的 sort 包实现了内置和用户自定义数据类型的排序功能.我们首先关注内置数据类型的排序. Example: package main import ( "fmt" &quo ...