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 ...
随机推荐
- OJ测试数据追溯方法
https://blog.csdn.net/iwts_24/article/details/79240987 我是从这个博客知道还有从比赛官方网站扒测试数据的方法,但是下面的链接有些是失效的. 所以我 ...
- Win7 VSCode 在线安装Rust语言及环境配置
睡前彻底解决在VSCode中,按F12不跳转到标准库源码的问题. 首先,如果装过离线版,卸载掉. 然后去官网下载 rustup-init.exe https://www.rust-lang.org/t ...
- Linux中ssh及scp的连接
1. 当你想获取另外一台电脑上的数据时,可以使用这个命令 scp -P 10022 root@172.30.83.173:~/ubuntu1.tar ./ -r 代表传输文件夹,直接传文件可以不加 ...
- Node.js实战5:操作系统与命令行。
Nodejs有一些内置的方法可以查询操作系统信息: 如: process.arch获取到系统是32位还是64位, process.platform可获取系统的类型. 例程: console.log(p ...
- 炫酷CSS3加载动画
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8&qu ...
- C#=>递归反转栈
原理,递归反转栈 using System; using System.Collections.Generic; using System.Linq; using System.Threading.T ...
- CodeChef Little Elephant and Balance
Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that L ...
- NGUI的CheckBox的使用(toggle script)
一,我们先添加一个sprite,选择sprite,右键选择attach,添加box collider, 然后右键选择attach,添加toggle script,得到如下图结果 1,但是如果你没有给U ...
- zabbix3.0自动发现磁盘并监控磁盘IO
Zabbix 版本:3.0 操作系统:Ubuntu16.04 操作环境,在被监控的主机上安装zabbix agent.安装方式为源码包安装. 简要安装步骤: 参考:https://www.zabbix ...
- 几张非常有意义的JavaScript基础学习思维图
分享几张对于学习JavaScript基础知识非常有意义的图,无论你的JavaScript级别如何,“温故而知新”完全可以从这些图中得到. 推荐理由:归类非常好,非常全面 JavaScript 数组 J ...