ural 1071. Nikifor 2
1071. Nikifor 2
Memory limit: 64 MB
Input
Output
Sample
input | output |
---|---|
127 16 |
3 |
Problem Source: Ural State Univerisity Personal Contest Online February'2001 Students Session
/**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} const int N = ;
int x, y;
int arr[N], len1, brr[N], len2; inline void Input()
{
cin >> x >> y;
} inline void Change(int *a, int &len, int x, int base)
{
len = ;
while(x)
{
a[len++] = x % base;
x /= base;
}
} inline void Solve()
{
for(int k = ; k <= x; k++)
{
Change(arr, len1, x, k);
Change(brr, len2, y, k); int index = ;
bool flag = ;
for(int j = ; j < len2; j++)
{
while(index < len1 && arr[index] != brr[j])
index++;
if(index < len1) index++;
else
{
flag = ;
break;
}
}
if(flag)
{
printf("%d\n", k);
return;
}
}
printf("No solution\n");
} int main()
{
freopen("c.in", "r", stdin);
Input();
Solve();
return ;
}
ural 1071. Nikifor 2的更多相关文章
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
- ural 2068. Game of Nuts
2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...
- ural 2067. Friends and Berries
2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...
- ural 2066. Simple Expression
2066. Simple Expression Time limit: 1.0 secondMemory limit: 64 MB You probably know that Alex is a v ...
- ural 2065. Different Sums
2065. Different Sums Time limit: 1.0 secondMemory limit: 64 MB Alex is a very serious mathematician ...
随机推荐
- chaper3_exerise_Uva1225_digit_counting
#include<iostream> #include<stdio.h> #include<cstring> using namespace std; ; int ...
- Git命令之上传与同步
操作步骤,可参考:http://blog.csdn.net/chenyufeng1991/article/details/47299461. 1.在本地仓库中,即项目目录下创建文件,如: 2.查看当前 ...
- eclipse 中添加工程 Some projects cannot be imported because they already exist in the workspace
第一次从外部文件导入HelloWorld工程到workspace目录中,成功. 删除后,再次从外部导入workspace目录提示 Some projects cannot be imported be ...
- Swift - 语言指南,来自github学习
@SwiftLanguage 更新于 2016-6-6,更新内容详见 Issue 55.往期更新回顾详见<收录周报> 这份指南汇集了 Swift 语言主流学习资源,并以开发者的视角整理编排 ...
- 三、jQuery--Ajax基础--Ajax全接触--Ajax在JS中的应用
Ajax的全称:Asynchronous JavaScript And XML(异步的 JavaScript 和 XML). Ajax不是某种编程语言,是一种在无需重新加载整个网页的情况下能够更新部分 ...
- MongoDB基本命令
1. 启动和停止MongoDB: 执行mongod命令启动MongoDB服务器.mongod有很多可配置的选项,我们通过mongod --help可以查看所有选项,这里仅介绍一些主要选项: - ...
- 22.访问者模式(Vistor Pattern)
using System; using System.Collections; namespace ConsoleApplication5 { /// <summary> /// 访问者模 ...
- 手机站点动态效果插件TouchSlide
今天看到TouchSlide插件,觉得非常不错,关于使用情况请看demo,下载地址:http://www.superslide2.com/TouchSlide/downLoad.html
- WPF MVVM模式下实现ListView下拉显示更多内容
在手机App中,如果有一个展示信息的列表,通常会展示很少一部分,当用户滑动到列表底部时,再加载更多内容.这样有两个好处,提高程序性能,减少网络流量.这篇博客中,将介绍如何在WPF ListView中实 ...
- hdu 4731 2013成都赛区网络赛 找规律
题意:找字串中最长回文串的最小值的串 m=2的时候暴力打表找规律,打表可以用二进制枚举