自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

转载 矩阵快速幂模板

矩阵快速幂和普通的快速幂差不多,注意单位矩阵E是对角线都是1、其他是零的矩阵#include<bits/stdc++.h>using namespace std;const int maxn = 100 + 10;int MOD;struct Mat{ int a[maxn][maxn]; int n, m;//n为行数,m为列数 Mat(int n,...

2018-04-29 20:54:38 114

转载 Codeforces-118D Caesar's Legions

aius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is notbeautiful if somewhere in the line there ...

2018-04-27 22:34:38 294

原创 二项式定理

实现二项式的运算:C(n,m)=n!/[m!(n-m)!]   例:c(5,2)=5!/(2!*(5-2)!)#include<iostream>using namespace std;int zuheshu(int a,int b){ int j=1; int ans=1; for(int i=a;i>a-b;i--) { ...

2018-04-24 18:07:23 520

原创 HDU-1061 Rightmost Digit(快速幂取余)

Problem DescriptionGiven a positive integer N, you should output the most right digit of N^N.  InputThe input contains several test cases. The first line of the input is a single integer T which is th...

2018-04-24 16:42:16 171

原创 快速幂

快速幂求a的b次方,将b转化为二进制相加形式,例3的11次方:转化为3^(2^3+2^1+2^0)int cifang(int a,int b){ int base=a; int ans=1; while(b!=0) { if(b&1) { ans*=base; } base*=...

2018-04-23 22:42:34 116

转载 Codeforces 892B- Wrath

Hands that shed innocent blood!There are n guilty people in a line, the i-th of them holds a claw with length Li. The bell rings and every person kills some of people in front of him. All people kill ...

2018-04-23 21:05:33 209

转载 第八届ACM省赛 K题 CF

DescriptionLYD loves codeforces since there are many Russian contests. In an contest lasting for T minutes there are n problems, and for the ith problem you can get ai−di∗ti points, where ai indicates...

2018-04-21 22:26:08 192

原创 Vigos- 1317 开心的金明 (01背包)

描述金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过N 元钱就行”。今天一早金明就开始做预算,但是他想买的东西太多了,肯定会超过妈妈限定的N 元。于是,他把每件物品规定了一个重要度,分为5 等:用整数1~5 表示,第5 等最重要。他还从因特网上查到了每件物品的价格(都是整...

2018-04-20 22:16:27 159

原创 Vijos-1334 NASA的食物计划

背景NASA(美国航空航天局)因为航天飞机的隔热瓦等其他安全技术问题一直大伤脑筋,因此在各方压力下终止了航天飞机的历史,但是此类事情会不会在以后发生,谁也无法保证,在遇到这类航天问题时,解决方法也许只能让航天员出仓维修,但是多次的维修会消耗航天员大量的能量,因此NASA便想设计一种食品方案,让体积和承重有限的条件下多装载一些高卡路里的食物.描述航天飞机的体积有限,当然如果载过重的物品,燃料会浪费很...

2018-04-20 20:36:59 193

转载 HDU-1712 ACboy needs your help(分组背包)

先发个不错的链接http://www.cppblog.com/Onway/archive/2010/08/09/122695.htmlACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he will gain from different course ...

2018-04-20 17:46:48 149

转载 HDU-2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活(部分背包)

Problem Description急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?后记:人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。月有阴晴圆缺,人有旦夕祸福,未来对于我们...

2018-04-19 17:28:20 186

原创 HDU-1114 Piggy-Bank 完全背包

Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple...

2018-04-18 17:10:33 156

原创 UVA—673 Parentheses Balance 括号匹配

You are given a string consisting of parentheses () and []. A string of this type is said to be correct:(a) if it is the empty string(b) if A and B are correct, AB is correct,(c) if A is correct, ...

2018-04-18 15:31:59 196

原创 HDU—1022Train Problem I

As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over t...

2018-04-16 22:26:11 116

转载 素数打表模板

这个打表的效率貌似很高,据说几乎到了线性时间(并不知道真假)!!bool visit[10100000]; int prime[10000000]; void init_prim() { memset(visit, true, sizeof(visit)); int num = 0; for (int i = 2; i <= n; ...

2018-04-16 19:04:43 774

原创 poj 1163 The Triangle

73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and e...

2018-04-15 17:11:33 110

原创 HDU-1241 Oil Deposits

The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th...

2018-04-15 15:47:04 200

原创 poj 1064 Cable master

Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to co...

2018-04-15 14:29:54 129

转载 Door Frames

Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. contin...

2018-04-11 22:43:51 380

转载 Position in Fraction

You have a fraction . You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.InputThe first contains three single positive integers a, b, c (1 ≤ a &...

2018-04-11 22:10:04 241

原创 并查集 POJ - 1611 The Suspects

Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to s...

2018-04-11 18:35:54 110

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除