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 ...
随机推荐
- MongoDb python连接
方式一:简写 client = MongClient() 方式二:指定端口和地址 client = MongoClient('localhost':27017) 方式三:使用URI --统一资源定位 ...
- 泛微e-cology OA Beanshell组件远程代码执行漏洞复现CNNVD-201909-1041
靶机 影响版本 泛微e-cology<=9.0 https://github.com/jas502n/e-cology 部署 复现 /weaver/bsh.servlet.BshServlet ...
- SELECT COUNT语句
数据库查询相信很多人都不陌生,所有经常有人调侃程序员就是CRUD专员,这所谓的CRUD指的就是数据库的增删改查. 在数据库的增删改查操作中,使用最频繁的就是查询操作.而在所有查询操作中,统计数量操作更 ...
- IntelliJ IDEA 中 Ctrl+Alt+Left/Right 失效
开发工具:Idea OS:Window 7 在idea中使用ctrl+b跟踪进入函数之后,每次返回都不知道用什么快捷键,在idea中使用ctrl+alt+方向键首先会出现与win7屏幕方向的快捷键冲突 ...
- jar 启动脚本
前段时间用springboot做项目后,每次重新发布都好麻烦, 所以写了个脚本来配合jenkins 发布: #!/bin/bash APP_NAME=application.jar function ...
- python-内置常量
引言 Python的内置常量不多,只有6个,分别是True.False.None.NotImplemented.Ellipsis.__debug__ 一.True 1.True是bool类型用来表示的 ...
- 微信小程序(5)--阅读器
最近用微信小程序写了一个图书阅读器,可以实现左右滑动翻页,按钮翻页,上下滚动,切换背景,控制字体大小.以及记住设置好的状态,如页面再次进来保留上次的背景色和字体大小. 由于暂时没有真实的数据接口,所以 ...
- Sass函数:数学函数-abs函数
abs( ) 函数会返回一个数的绝对值. >> abs(10) 10 >> abs(-10) 10 >> abs(-10px) 10px >> abs( ...
- procixx地址
\\192.168.35.7\Download\Builds\procixx_psoc
- java 计算时间差
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date d1 = df.parse(&quo ...