数论
文章平均质量分 70
ccyy-
这个作者很懒,什么都没留下…
展开
-
hdu 4734 F(x)(数位dp,记忆化深搜,灵活题)
For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1. Now you are given two numbers A and B, please calculate ho原创 2015-05-09 21:49:41 · 523 阅读 · 0 评论 -
hdu4466 将长度为n线段瓜分成若干个相似三角形,有多少种分法(划分dp)
三角形顺序不同视为不同方案。题解:http://www.cnblogs.com/jianglangcaijin/p/3465526.html#include#define ll long long #define mod 1000000007#define maxn 5000000using namespace std; int dp[maxn+5];int power[原创 2016-04-18 00:50:02 · 866 阅读 · 0 评论 -
zoj3596 求一个数N的最小的一个倍数中包含M个不同的数字
ps:这种bug我要是会调试就不用这么傻逼地看一天了。。。。。。。。。。。#includeusing namespace std;struct node{ int a,b,c,e; node(int aa=0,int bb=0,int cc=0,int ee=0){ a=aa;b=bb;c=cc;e=ee; } bool oper原创 2016-03-21 22:38:44 · 1416 阅读 · 0 评论 -
计算1到N中1出现的次数(分类讨论,数论)
这题很有意思。给定一个十进制正整数N,写下从1开始,到N的所有正数,计算出其中出现所有1的个数。例如:n = 12,包含了5个1。1,10,12共包含3个1,11包含2个1,总共5个1。想象空间——————————————————————————————————原创 2016-01-29 19:20:18 · 609 阅读 · 0 评论 -
【codechef】判断一个数是否为某组勾股数的最大数?
https://www.codechef.com/OCT15/problems/ADTRvector generate(int n) { vector input(n + 1, true); vector ans(n + 1, false); int sqrtN = (int)sqrt(n); for (int i = 2; i <= sqrtN; i原创 2015-10-31 18:46:54 · 1395 阅读 · 0 评论 -
SEERC15 求一个正整数n,使得a+n和b+n的LCM值最小
http://codeforces.com/gym/100818 有一个坑点:国外的自然数居然是不包括0的!!!#includeusing namespace std;vector v;long long gcd(long long x, long long y){ if (y == 0) return x; return gcd(y, x%y);}int main(原创 2015-12-08 15:46:11 · 1116 阅读 · 0 评论 -
ACM-ICPC 2015 Asia Tsukuba Regional Online Open Contest B(两挡板之间放着圆球,求挡板最短距离)
一开始想得很麻烦,然后发现又读漏了可以简化题目的信息……好不容易想到的方法一定要记录一下。。。#include #include #include #include//ll dx[4]={0,0,-1,1};ll dy[4]={-1,1,0,0}; #include// #include #include #include #include #include原创 2015-11-30 12:00:28 · 771 阅读 · 0 评论 -
将无限循环小数转化为分数
3个例子就懂了。。0.3——3是循环节,应是3/(10-1)=1/3 0.31——31是循环节,是31/(100-1)=31/99。0.12——12是循环节,是12/(100-1)=4/33。原创 2015-12-14 10:20:51 · 942 阅读 · 1 评论 -
hihocoder 1166 交换代数|HDU 4870 Rating 等(区间翻转,高斯消元求期望)
少女幽香这几天正在学习交换代数,然而她什么也没有学会,非常痛苦。于是她开始玩起了一个简单的小游戏,来放松一下。地面上一共有n个球,一开始有一些是黑色的,有一些是白色的。每次她随机选择一个区间(一共有n(n+1)/2个区间,每个区间有相等的概率被选择),把这个区间的颜色反转,即将该区间中白球变黑球,黑球变白球。现在她想要知道期望情况下,多少次反转能够使得整个区间都是白色的。输入第原创 2015-05-12 11:26:35 · 861 阅读 · 0 评论 -
Dhaka2014 I Volume of Revolution (积分求体积)
英语又跪了……意思是给你一个曲线的方程(a平头椎台的体积计算公式:V = 1/3*h*(S1+S2*sqrt(S1*S2)曲线体积积分:∫(下a上b) π*f(x)*f(x)dx#include#define pi 3.1415926535using namespace std;double x[10],y[105],z[210];int main(){原创 2015-08-29 19:17:59 · 756 阅读 · 0 评论 -
ZOJ 3866 Cylinder Candy(对体积和表面积 积分)
Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinder with radius r mm and height h mm.The candy center needs to be covered with a u原创 2015-07-12 13:50:01 · 711 阅读 · 0 评论 -
【百度之星初赛2】魔法因子|乘某个数首末位互换(数学,灵活题)
有人说:人类是自己一步步进化的,而数学是上帝亲手创造的。度度熊最近也正沉醉于数学之美中,它发现了一种神奇的数字,取名曰:魔法因子。将因子记为X,如果有一些整数与这些因子做乘法后,结果仍然是整数,同时,结果数字的首位和末位会换交换位置,而其他位置上的数字恰好不变!这时X被认为是一个魔法因子。需要注意的是,用来相乘的这些整数不会含有前导0,但是如果交换的结果有前导0,又恰好是乘法的结果,这时仍原创 2015-05-31 23:04:46 · 906 阅读 · 0 评论 -
【codechef】Chef and Strange Formula(找规律,灵活题)
Input:5 71 2 3 4 5Output:6ExplanationF(1) = 1 * (1! + 1) = 2F(2) = 1 * (1! + 2) + 2 * (2! + 2) = 3 + 8 = 11F(3) = 1 * (1! + 3) + 2 * (2! + 3) + 3 * (3! + 3) = 4 + 10 + 27 = 41F(4) = 1 * (1!原创 2015-05-15 20:59:32 · 532 阅读 · 0 评论 -
poj 1410 Intersection (判两直线是否相交)
You are to write a program that has to decide whether a given line segment intersects a given rectangle. An example: line: start point: (4,9) end point: (11,2) rectangle: left-top: (1,5) r原创 2015-05-08 08:51:54 · 592 阅读 · 0 评论 -
矩阵快速幂【集合】
Clarke is a patient with multiple personality disorder. One day, Clarke turned into a researcher, did a research on digits.He wants to know the number of positive integers which have a length in[l原创 2016-02-06 16:54:02 · 605 阅读 · 0 评论