Prime Land
http://poj.org/problem?id=1365
题意:给定一个数字n的拆分形式,然后让你求解n-1的值;
解析:直接爆搞
// File Name: poj1365.cpp
// Author: bo_jwolf
// Created Time: 2013骞?0鏈?9鏃?鏄熸湡涓?21:29:25 #include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime> using namespace std;
vector<int> prime, ans;
const int maxn = 40000;
int unprime[ maxn ];
int main(){
unprime[ 0 ] = unprime[ 1 ] = true;
for( int i = 2; i < maxn; ++i ){
if( !unprime[ i ] ){
prime.push_back( i );
for( int j = i + i; j < maxn; j += i ){
unprime[ j ] = true;
}
}
}
int n, p;
string line;
while( getline( cin, line ),line[ 0 ] != 48 ){
ans.clear();
istringstream stream( line );
long long sum = 1;
while( stream >> n >> p ){
while( p-- ){
sum *= n;
}
} sum -= 1;
for( int i = prime.size() - 1; i >= 0; --i ){
if( sum % prime[ i ] == 0 ){
ans.push_back( prime[ i ] );
int temp = 0;
while( sum % prime[ i ] == 0 ){
sum /= prime[ i ];
temp++;
}
ans.push_back( temp );
}
}
for( int i = 0 ; i < ans.size(); ++i ){
cout << ans[ i ] << ( i == ans.size() - 1 ?'\n':' ' );
}
}
return 0;
}
Prime Land的更多相关文章
- POJ 1365 Prime Land(数论)
题目链接: 传送门 Prime Land Time Limit: 1000MS Memory Limit: 10000K Description Everybody in the Prime ...
- [POJ 1365] Prime Land
Prime Land Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3211 Accepted: 1473 Descri ...
- [暑假集训--数论]poj1365 Prime Land
Everybody in the Prime Land is using a prime base number system. In this system, each positive integ ...
- 数学--数论--POJ1365——Prime Land
Description Everybody in the Prime Land is using a prime base number system. In this system, each po ...
- POJ1365 - Prime Land(质因数分解)
题目大意 给定一个数的质因子表达式,要求你计算机它的值,并减一,再对这个值进行质因数分解,输出表达式 题解 预处理一下,线性筛法筛下素数,然后求出值来之后再用筛选出的素数去分解....其实主要就是字符 ...
- POJ 1365 Prime Land(整数拆分)
题意:感觉题意不太好懂,题目并不难,就是给一些p和e,p是素数,e是指数,然后把这个数求出来,设为x,然后让我们逆过程输出x-1的素数拆分形式,形式与输入保持一致. 思路:素数打表以后正常拆分即可. ...
- POJ1365 Prime Land【质因数分解】【素数】【水题】
题目链接: http://poj.org/problem?id=1365 题目大意: 告诉你一个数的质因数x的全部底数pi和幂ei.输出x-1的质因数的全部底数和幂 解题思路: 这道题不难.可是题意特 ...
- 筛选法 || POJ 1356 Prime Land
英文题读不懂题==质数幂的形式给你一个数 把它减一再用质数幂的形式表示出来 *解法:质数从小到大模拟除一遍,输入有点别扭 #include <iostream> #include < ...
- pku1365 Prime Land (数论,合数分解模板)
题意:给你一个个数对a, b 表示ab这样的每个数相乘的一个数n,求n-1的质数因子并且每个指数因子k所对应的次数 h. 先把合数分解模板乖乖放上: ; ans != ; ++i) { ) { num ...
随机推荐
- appfabric 简单应用
http://msdn.microsoft.com/en-us/library/ee790941(v=azure.10).aspx Preparing the Visual Studio Projec ...
- Load a script file in sencha, supports both asynchronous and synchronous approaches
//http://www.sencha.com/forum/showthread.php?188318-Ext.Loader.loadScriptFile-wrong-URL Ext.Loader.l ...
- 通过 SignalR 类库,实现 ASP.NET MVC 的实时通信
在本文中,您将学到在现有 ASP.NET MVC 框架的 CRUD 项目中,如何使用 SignalR 类库,显示来自数据库的实时更新.在这一主题中,我们将重点放在在现有 ASP.NET MVC 框架的 ...
- freshStartTail 第一次启动时 抛弃旧的日志
freshStartTail [on/off] (requires v8.18.0+) Default: off This is used to tell rsyslog to seek to the ...
- Fedora 17下交叉编译vlc-2.0.6-win32小记
关于编译windows下的vlc网上的教程除了翻译N年前wiki官网的那些蚂蚁文之外,可以说基本没啥参考意义和价值.因为那些都是非常老的版本,0.8.x或者1.x.x,而我这个人有喜欢新鲜事儿,所以就 ...
- Oracle Form Developer: Folder FRM-99999 Error 14212
Question: 做FOLDER文件夹功能,打开FORM错误提示: FRM-99999:出现1412错误.有关该错误的详细信息,请参阅发行说明文件(relnotes) Answer: 原因是FOLD ...
- ununtu卸载软件
sudo apt-get remove vim
- 结构体dtype_t
/* SQL data type struct */ typedef struct dtype_struct dtype_t; struct dtype_struct{ unsigned mtype: ...
- 用if else 判断是不是7的倍数等
static void Main(string[] args) { while (true) { int b; ...
- Android中界面实现全屏显示的两种方式
在开发android的应用当中,我们会遇到将一些界面设置为全屏显示的格式,有两种实现的方法.其一是在Java代码中实现,其二是在配置文件中实现. 1. 在Java代码中设置 super.onCreat ...