POJ 2190
直接枚举0~X就可以了。。。我开始竟然往扩展欧几里德定理想了,呃呃---
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std; char st[20]; int main()
{
//freopen("t.txt", "r", stdin);
gets(st);
int ans = 0;
int pos = 0;
for (int i = 0; i < 10; i++)
if (st[i] == '?')
pos = 10 - i;
else if (st[i] == 'X')
ans += 10 * (10 - i);
else
ans += (st[i] - '0') * (10 - i);
for (int i = 0; i <= 9; i++)
if ((ans + i * pos) % 11 == 0)
{
printf("%d\n", i);
return 0;
}
if ((ans + 10 * pos) % 11 == 0 && pos == 1)
{
printf("X\n");
return 0;
}
printf("-1\n");
return 0;
}
POJ 2190的更多相关文章
- POJ 2190 模拟
按照题意模拟就好- 注意"X"只能出现在最后一位... // by SiriusRen #include <cstdio> using namespace std; c ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 转载:poj题目分类(侵删)
转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码) ...
- poj和hdu部分基础算法分类及难度排序
最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
随机推荐
- linux udev 机制【转】
本文转载自:http://blog.csdn.net/yyt8yyt8/article/details/8020154 1. Linux的热插拔事件由kernel通过中断发现(比如,USB设备插入系统 ...
- Linux - 如何关闭防火墙
关闭防火墙,就可以外部访问了.不受端口限制.生产环境,最好开启防火墙,开启部分端口. 1.永久有效 开启: chkconfig iptables on 关闭: chkconfig iptables o ...
- Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
安卓出现如下错误,需要增加FLAG_ACTIVITY_NEW_TASK标志 Intent intent1 = new Intent(getApplicationContext(), CameraAct ...
- Max Sum--hdoj 1003 dp
Max Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- Constructing Roads --hdoj
Constructing Roads Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) ...
- 快速排序c++实现 快排C++代码实现
快速排序c++实现 快排C++ 第一.算法描述 快速排序由C. A. R. Hoare在1962年提出,该算法是目前实践中使用最频繁,实用高效的最好排序算法, 快速排序算法是采用分治思想的算法,算法分 ...
- guice基本使用,配置模块的两种方式(三)
guice是使用module进行绑定的,它提供了两种方式进行操作. 第一种是继承AbstractModule抽象类. package com.ming.user.test; import com.go ...
- week1 notebook1
初识Python 一.python介绍 - 解释器: cpython(默认使用) ipython(shell) jpython(java) ironpython rubypython - 编码: as ...
- 30秒就能理解的JavaScript优秀代码
数组 arrayMax 返回数组中的最大值. 将Math.max()与扩展运算符 (...) 结合使用以获取数组中的最大值. const arrayMax = arr => Math.max(. ...
- (转)一个vue路由参数传递的注意点
首先我的路由的定义 { path: '/b', name: 'B', component: resolve => require(['../pages/B.vue'], resolve) } 我 ...