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 ...
随机推荐
- Vagrant 手册之网络 - 概述及基本用法
原文地址 - 概述 原文地址 - 基本用法 为了访问创建的 Vagrant 环境,Vagrant 为端口转发.连接公共网络.创建私有网络等功能暴露了一些高层网络选项. 高层网络选项用于提供可以跨 pr ...
- cts-on-gsi测试流程
测试前提: 1.发货user版本 2.selinux:Enable 3.连接ADB,stay awake 4.烧录XXX申请的key 5.外网环境(ipv6) ATV9测试准备(正常准备环境+fast ...
- poj1742Coins(多重背包)
People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony ...
- webpack2.0 基本使用
webpack是一款前端模块打包工具, 它的出现是由于现代web开发越来越复杂,如果还是像原来那样把所有的js代码都写到一个文件中,维护非常困难.而解决复杂化的方法通常是分而治之,就是把复杂化的东西进 ...
- android项目的目录结构讲解
参考书籍:<第一行代码Android> 一:android项目的目录结构讲解 1..gradle和.idea 这两个目录下放置的都是Android Studio自动生成的一 ...
- Erueka异常
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | ...
- dp或dfs(01背包问题)
链接:https://ac.nowcoder.com/acm/contest/993/C来源:牛客网题意:n头牛,给出它们的H高度,问这些牛的高度叠加起来大于等于书架高度,问叠加后的高度与书架的差值最 ...
- 5、numpy——切片和索引
1.一维数组 1.1 一维数组很简单,基本和列表一致.ndarray 数组可以基于 0 - n 的下标进行索引. 切片对象可以通过内置的 slice 函数,并设置 start, stop 及 step ...
- TensorFlow 安装报错的解决办法
最近关注了几个python相关的公众号,没事随便翻翻,几天前发现了一个人工智能公开课,闲着没事,点击了报名. 几天都没有音信,我本以为像我这种大龄转行的不会被审核通过,没想到昨天来了审核通过的电话,通 ...
- how to use epoll with python
1 import socket, select 2 3 EOL1 = b'\n\n' 4 EOL2 = b'\n\r\n' 5 response = b'HTTP/1.0 200 OK\r\nDate ...