CF Gym 100637J Superfactorial numeral system (构造)
题意:给一个式子
,ak,k>2时,0<=ak<k;ai都是整数,给你p,q让你求一组ak。
题解:构造,每次除掉q取整得到ai,然后减一减
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<algorithm> using namespace std;
typedef unsigned long long ull; int main()
{
ull p,q;
scanf("%I64u%I64u",&p,&q);
ull fac = ;
ull ai = p/q;
printf("%I64u",ai);
p = (p-ai*q)*(fac);
while(p){
ai = p/q;
printf(" %I64u",ai);
p = (p - ai*q)*(++fac);
}
return ;
}
CF Gym 100637J Superfactorial numeral system (构造)的更多相关文章
- Gym - 100637J
On the most perfect of all planets i1c5l various numeral systems are being used during programming c ...
- CF Gym 102028G Shortest Paths on Random Forests
CF Gym 102028G Shortest Paths on Random Forests 抄题解×1 蒯板子真jir舒服. 构造生成函数,\(F(n)\)表示\(n\)个点的森林数量(本题都用E ...
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...
- Codeforces Gym 100425H H - Football Bets 构造
H - Football BetsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- cf 323A A. Black-and-White Cube 立体构造
A. Black-and-White Cube time limit per test 1 second memory limit per test 256 megabytes input stand ...
- cf 323A A. Black-and-White Cube 立体构造 不知道为什么当k为奇数时构造不出来 挺有趣的题目吧
A. Black-and-White Cube time limit per test 1 second memory limit per test 256 megabytes input stand ...
- [ 9.24 ]CF每日一题系列—— 468A构造递推
Description: 1 - n个数问你能否经过加减乘除这些运算n -1次的操作得到24 Solutrion: 一开始想暴力递推,发现n的范围太大直接否决,也否决了我的跑dfs,后来就像肯定有个递 ...
- Codeforces Round #298 (Div. 2) E. Berland Local Positioning System 构造
E. Berland Local Positioning System Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.c ...
- CF gym 101933 K King's Colors —— 二项式反演
题目:http://codeforces.com/gym/101933/problem/K 其实每个点的颜色只要和父亲不一样即可: 所以至多 i 种颜色就是 \( i * (i-1)^{n-1} \) ...
随机推荐
- 使用 Addr2line 将函数地址解析为函数名
用 Addr2line 将函数地址解析为函数名 原文链接:http://www.ibm.com/developerworks/cn/linux/l-graphvis/ Addr2line 工具(它是标 ...
- pandas基础(2)_多重索引
1:多重索引的构造 >>> #下面显示构造pd.MultiIndex >>> df1=DataFrame(np.random.randint(0,150,size= ...
- 51nod1241(连续上升子序列)
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1241 题意:中文题诶- 思路:通过观察我们不难发现就是找连续 ...
- IT兄弟连 JavaWeb教程 使用Servlet实现在页面中显示随机数
在com.xdl.servlet包下定义RandomServlet类并HttpServlet类,在该类中生成随机数并发送给客户端.RandomServlet类详细代码如下: package com.x ...
- C 语言实例 - 求两数最小公倍数
C 语言实例 - 求两数最小公倍数 用户输入两个数,其这两个数的最小公倍数. 实例 - 使用 while 和 if #include <stdio.h> int main() { int ...
- 条件分页 分页条件和页参数传递方式一 超链接拼串 方式二 使用查询表单searchForm
<%-- Created by IntelliJ IDEA. User: jie Date: 2019/5/10 Time: 20:00 To change this template use ...
- 判断jquery对象是否在执行动画
function isAnimated($obj){ var flag=false; if($obj.is(":animated")){ flag=true; } return f ...
- css圆角不圆和1px方案
1.圆角不圆 比如需要我们画一个 r 为 5px 的圆,如果我们使用 rem 作为单位,我们很快会发现在一些机型上的图案不圆,会呈现椭圆形.这是由于 rem 转 px 会存在精度丢失问题. 所以这个时 ...
- POJ1830(异或高斯消元)
对于某个开关,都有n个选项可能影响它的结果,如果会影响,则系数为1,否则系数为0:最后得到自由元的个数,自由元可选0也可选1. #include <cstdio> #include < ...
- AtCoder Beginner Contest 071 ABCD
1001 求个绝对值比较大小喽 1002 把字符串出现的字母记录一下,然后遍历a-z,谁第一个没出现就输出谁 1003 Problem Statement We have N sticks with ...