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的更多相关文章

  1. Monthly Income Report – August 2016

    原文链接:https://marcoschwartz.com/monthly-income-report-august-2016/ Every month, I publish a report of ...

  2. [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 ...

  3. 浙大月赛ZOJ Monthly, August 2014

    Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...

  4. [转载]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 ...

  5. 135 - ZOJ Monthly, August 2014

    135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][ ...

  6. 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 ...

  7. August 31st 2016 Week 36th Tuesday

    A friend without faults will never be found. 没有缺点的朋友是永远找不到的. You can't find a friends without faults ...

  8. August 30th 2016 Week 36th Tuesday

    If you keep on believing, the dreams that you wish will come true. 如果你坚定信念,就能梦想成真. I always believe ...

  9. August 29th 2016 Week 36th Monday

    Every has the capital to dream. 每个人都有做梦的本钱. Your vision, our mission. That is an advertisment of UMo ...

  10. August 28th 2016 Week 36th Sunday

    What doesn't kill you makes you stronger. 那些没有彻底击败你的东西只会让你更强大. Where there is life, there is hope, a ...

随机推荐

  1. pandas向左移动非空单元格

    碰到个小问题, 因为需要更改excel 的行为. 处理最多的还是excel的事, 不过看起来是excel.实际上对pandas 的库的熟悉.读取,更改,应用等等,方法. 十分有用. 先说需求,本来的表 ...

  2. Vue作用域插槽:用作循环结构的模版

    一 项目结构 二 App组件 <template> <div id="app"> <!-- 子组件 --> <todos :list=&q ...

  3. upc组队赛16 Winner Winner【位运算】

    Winner Winner 题目链接 题目描述 The FZU Code Carnival is a programming competetion hosted by the ACM-ICPC Tr ...

  4. SEC7 - MySQL 查询语句--------------进阶3:排序查询

    # 进阶3:排序查询 /* 引入: select * from employees; 语法: select 查询列表 from 表 [where 筛选条件] order by 排序的列表 asc/de ...

  5. pgsql删除重复记录

    如下: DELETE FROM categories a WHERE ( a.id, a.name, a.parent_id ) ) ) 关键点:oracle中有内部id为rowid, 在postgr ...

  6. Netty基础-BIO/NIO/AIO

    同步阻塞IO(BIO): 我们熟知的Socket编程就是BIO,每个请求对应一个线程去处理.一个socket连接一个处理线程(这个线程负责这个Socket连接的一系列数据传输操作).阻塞的原因在于:操 ...

  7. Codeforces 1119C(思维)

    题面 传送门 分析 这种题的重点是寻找不变量 我们发现如果改变4个角,则每一行和每一列的xor和不会改变(1^0=0^1) 所以只要算出异或和然后比较就可以 代码 #include<iostre ...

  8. P3740 [HAOI2014]贴海报

    题目描述 Bytetown城市要进行市长竞选,所有的选民可以畅所欲言地对竞选市长的候选人发表言论.为了统一管理,城市委员会为选民准备了一个张贴海报的electoral墙. 张贴规则如下: electo ...

  9. Spark链接hive时 “HikariCP” 问题

    IDE本地调试和spark-shell调试报错: Caused by: org.datanucleus.exceptions.NucleusUserException: The connection ...

  10. python数字图像处理(五) 图像的退化和复原

    import cv2 import numpy as np import matplotlib.pyplot as plt import scipy import scipy.stats %matpl ...