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 ...
随机推荐
- python基础——多重继承
python基础——多重继承 继承是面向对象编程的一个重要的方式,因为通过继承,子类就可以扩展父类的功能. 回忆一下Animal类层次的设计,假设我们要实现以下4种动物: Dog - 狗狗: Bat ...
- 第一个JAVA创建
1.file-new-java project 创建项目文件夹 2.在项目文件夹new-class 3.java对大小写比较敏感 输入代码 public class HELLOWORD { publ ...
- 早上3:30左右起来发现时候电脑在一致叫唤就是一个usb的接口可能是鼠标
然后看了下也没有网络了,早上起来就打了一个电话给网管,就开通了.是没有及时开通.
- git 提交代码的流程
[root@ok-T IT-DOC]# ls hx-海星-wifi.rd web收藏.txt [root@ok-T IT-DOC]# git status -s ?? "web\346\22 ...
- 《CLR via C#》读书笔记(1)CLR执行模型
1.1 释义 CLR 公共语音运行时 Common Language Runtime CTS 通用类型系统 Common Type System CTS.CLS是CLR的核心 CLS 通用语言规范 C ...
- MVC – 4.mvc初体验(2)
5.显示学员列表 效果 数据表 5.1 首先,在文件夹Models新建一个新建项(W),选择ADO.NET 实体数据模型 (SingleTest.edmx) 5.2 建一个控制器,StudentsCo ...
- C#关键字ref和out
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Di ...
- .net转的时间戳用java去解析的代码
/// <summary> /// 转换成java解析一致的时间戳 /// </summary> /// <param name="time"> ...
- sdut 2441 屠夫与狼
屠夫和狼 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...
- sublime text 全局搜索
Ctrl+Shift+F Mac下是commadn+Shift+F 在下面Find中填入需要搜索的关键字 点击find