题意:给定两个数G,T,求a,b使gcd(a,b)=G,lcm(a,b)=T;解题思路:1.T%G==0,否则无解。
2.输出a=gcd(a,b)=G,b=lcm(a,b)=T; 1 //Accepted 0 KB 16 ms 2 #include 3 #inclu...
分类:
其他好文 时间:
2014-05-26 02:47:24
阅读次数:
208
题目:The sum of the squares of the first ten
natural numbers is,12 + 22 + ... + 102 = 385The square of the sum of the first
ten natural numbers is,(1 + ...
分类:
其他好文 时间:
2014-05-26 02:15:16
阅读次数:
216
输入一个字符串(长度在100以内),统计其中数字字符出现的次数。样例输入Ab100cd200样例输出6#include"stdio.h"int main(){
char a[100]; int i; int sum=0; scanf("%s",a); for(i=0;...
分类:
其他好文 时间:
2014-05-26 00:09:23
阅读次数:
193
题目:输入一个整数s,打印出所有和为s的连续整数序列(至少含有2个数)。例如输入9,则输出2、3、4和4、5两个序列
方案一:由于序列至少要2个数,则两个数上限值为(1+s)/2,我们可以枚举该序列的起点和终点求所有满足的序列。时间复杂度为O(n^2),效率比较低
方案二:我们设置两个指针start和end分别表示当前序列的起点和终点,并记序列和为sum。当sum = s的时候输出这个...
分类:
其他好文 时间:
2014-05-25 18:18:18
阅读次数:
191
,,杭电把比赛关了代码都找不到了。。
无责任民科还是mark一下好了。。
HDU 4823 Energy Conversion
把式子变换一下发现是一个等比数列,快速幂即可。
HDU 4824 Disk Schedule
开始没注意一个环只有一个点的条件,差点变成NP。。因为要回到起点,就是一个双调dp
跟poj 2677差不多
HDU 4825 Xor Sum
字典树上的贪心,把...
分类:
其他好文 时间:
2014-05-25 10:16:01
阅读次数:
293
题目:
Given an array S of n integers, are there elements a, b, c in S such that a + b + c =
0? Find all unique
triplets in the array which gives the sum of zero.
Note:
Elements...
分类:
其他好文 时间:
2014-05-25 00:39:37
阅读次数:
343
http://poj.org/problem?id=3463
大致题意:给出一个有向图,从起点到终点求出最短路和次短路的条数之和。
解法:
用到的数组:dis[i][0]:i到起点的最短路,dis[i][1]:i到起点的严格次短路
vis[i][0],vis[i][1]:同一维的vis数组,标记距离是否已确定
sum[i][0]:i到起点的最短路条数,sum[i][1]:...
分类:
其他好文 时间:
2014-05-24 21:50:31
阅读次数:
287
之所以说leetcode的测试用例有问题,是因为我刚开始理解错了题意,写下了如下的错误的代码。但是却AC了。
错误代码为:
bool canJump(int A[], int n) {
if(n == 0) return true;
int sum = 0; //记录当前的最远距离
int i = 0;
...
分类:
其他好文 时间:
2014-05-24 19:45:57
阅读次数:
1081
接到zz的任务,实现自动化处理nagios某项报警脑海里有个印象,这个功能之前线下做过实验一、首先必须查看下nagios的官方文档,确认可行,以下是笔者整理的一些自认为有用的信息1)了解命令的定义方法WritingEventHandlerCommandsEventhandlercommandswilllikelybeshellorperlsc..
分类:
移动开发 时间:
2014-05-24 17:03:11
阅读次数:
476
An integer is divisible by 3 if the sum of its digits is also divisible by 3. For example, 3702 is divisible by 3 and 12 (3+7+0+2) is also divisible by 3. This property also holds for the integer 9.
...
分类:
其他好文 时间:
2014-05-24 14:30:47
阅读次数:
208