USACO dualpal
/*
ID:kevin_s1
PROG:dualpal
LANG:C++
*/ #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector> using namespace std; int N,S;
vector<int> result; bool isPalindromic(string num){
bool flag = true;
int len = num.length();
for(int i = 0; i <= len/2; i++){
if(num[i] != num[len - i - 1]){
flag = false;
}
}
if(num[0] == '0' || num[len - 1] == '0')
flag = false;
return flag;
} string trans(int num,int base){
string str;
while(num > 0){
str += num % base + '0';
num = num / base;
}
reverse(str.begin(),str.end());
return str;
} int main(){ freopen("dualpal.in","r",stdin);
freopen("dualpal.out","w",stdout);
cin>>N>>S;
int index = 0;
for(int i = S + 1; index < N; i++){
int x = i;
int count = 0;
for(int base = 2; base <= 10; base++){
string num = trans(x,base);
if(isPalindromic(num)){
count++;
}
}
if(count >= 2){
index++;
result.push_back(x);
}
}
vector<int>::iterator iter = result.begin();
for(;iter != result.end();iter++){
cout<<*iter<<endl;
}
return 0;
}
提交结果:
USER: Kevin Samuel [kevin_s1]
TASK: dualpal
LANG: C++ Compiling...
Compile: OK Executing...
Test 1: TEST OK [0.000 secs, 3504 KB]
Test 2: TEST OK [0.000 secs, 3504 KB]
Test 3: TEST OK [0.027 secs, 3504 KB]
Test 4: TEST OK [0.000 secs, 3504 KB]
Test 5: TEST OK [0.000 secs, 3504 KB]
Test 6: TEST OK [0.014 secs, 3504 KB]
Test 7: TEST OK [0.003 secs, 3504 KB] All tests OK. YOUR PROGRAM ('dualpal') WORKED FIRST TIME! That's fantastic
-- and a rare thing. Please accept these special automated
congratulations.
Here are the test data inputs:
------- test 1 ----
5 1
------- test 2 ----
9 10
------- test 3 ----
15 9900
------- test 4 ----
10 90
------- test 5 ----
12 125
------- test 6 ----
12 1900
------- test 7 ----
8 500
Keep up the good work!
Thanks for your submission!
版权声明:本文博主原创文章,博客,未经同意不得转载。
USACO dualpal的更多相关文章
- USACO chapter1
几天时间就把USACO chapter1重新做了一遍,发现了自己以前许多的不足.蒽,现在的程序明显比以前干净很多,而且效率也提高了许多.继续努力吧,好好的提高自己.这一章主要还是基本功的训练,没多少的 ...
- USACO . Your Ride Is Here
Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often co ...
- 【USACO 3.1】Stamps (完全背包)
题意:给你n种价值不同的邮票,最大的不超过10000元,一次最多贴k张,求1到多少都能被表示出来?n≤50,k≤200. 题解:dp[i]表示i元最少可以用几张邮票表示,那么对于价值a的邮票,可以推出 ...
- USACO翻译:USACO 2013 NOV Silver三题
USACO 2013 NOV SILVER 一.题目概览 中文题目名称 未有的奶牛 拥挤的奶牛 弹簧牛 英文题目名称 nocow crowded pogocow 可执行文件名 nocow crowde ...
- USACO翻译:USACO 2013 DEC Silver三题
USACO 2013 DEC SILVER 一.题目概览 中文题目名称 挤奶调度 农场航线 贝西洗牌 英文题目名称 msched vacation shuffle 可执行文件名 msched vaca ...
- USACO翻译:USACO 2014 DEC Silver三题
USACO 2014 DEC SILVER 一.题目概览 中文题目名称 回程 马拉松 奶牛慢跑 英文题目名称 piggyback marathon cowjog 可执行文件名 piggyback ma ...
- USACO翻译:USACO 2012 FEB Silver三题
USACO 2012 FEB SILVER 一.题目概览 中文题目名称 矩形草地 奶牛IDs 搬家 英文题目名称 planting cowids relocate 可执行文件名 planting co ...
- USACO翻译:USACO 2012 JAN三题(3)
USACO 2012JAN(题目三) 一.题目概览 中文题目名称 放牧 登山 奶牛排队 英文题目名称 grazing climb lineup 可执行文件名 grazing climb lineup ...
- USACO翻译:USACO 2012 JAN三题(2)
USACO 2012 JAN(题目二) 一.题目概览 中文题目名称 叠干草 分干草 奶牛联盟 英文题目名称 stacking baleshare cowrun 可执行文件名 stacking bale ...
随机推荐
- hdu1869六度分离,spfa实现求最短路
就是给一个图.假设随意两点之间的距离都不超过7则输出Yes,否则 输出No. 因为之前没写过spfa,无聊的试了一下. 大概说下我对spfa实现的理解. 因为它是bellmanford的优化. 所以之 ...
- Robotium原则的实施源代码分析
从前面的章节<Robotium源代码分析之Instrumentation进阶>中我们了解到了Robotium所基于的Instrumentation的一些进阶基础.比方它注入事件的原理等,但 ...
- hadoop-1.1.2 在Windows环境下的部署
1:先安装Cygwin 参考http://blog.csdn.net/wind520/article/details/9223003 2:下载 3:解压在C:\cygwin\hadoop1 4:配置 ...
- Threejs 它可以在建立其内部房间效果可见
Threejs 中建立可看到其内部的房间效果 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协 ...
- Lua相关的知识
http://stackoverflow.com/questions/5438751/how-to-debug-lua-remotely http://cn.bing.com/search?q=org ...
- Python 显示LinkedIn用户作业
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-18 @author: guaguastd @name: j ...
- 写你自己struts1框架
前言 文本 它们的定义Struts1 commons-digester.jar解析XML 实现XML标签到对象的转换 1.依据目标XML的结构定义解析规则文件 參照rule.xml 2.创建集合对象接 ...
- MongoDB最新版本3.2.9下载地址
https://downloads.mongodb.com/win32/mongodb-win32-x86_64-enterprise-windows-64-3.2.9.zip?_ga=1.22538 ...
- 上Mysql com.mysql.jdbc.StatementImpl$CancelTask内存泄漏问题和解决方法
近来在负责公司短信网关的维护及建设,随着公司业务发展对短信依赖越来越严重了,短信每天发送量也比曾经每天40多w发送量暴增到每天达到200w发送量.由于是採用Java做发送底层,压力递增情况下不可避免的 ...
- * 类描写叙述:字符串工具类 类名称:String_U
/****************************************** * 类描写叙述:字符串工具类 类名称:String_U * ************************** ...