2013
11-09

# 青蛙的约会

1 2 3 4 5

4

import java.util.Scanner;

public class Main {

static long x0, y0;

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long x = scan.nextInt();
long y = scan.nextInt();
long m = scan.nextInt();
long n = scan.nextInt();
long L = scan.nextInt();
x = x % L;
y = y % L;
if (x > y) {
long t = y;
y = x;
x = t;
t = n;
n = m;
m = t;
}
long a = Math.abs(m - n);
long b = -L;
long c;
if (m > n) {
c = y - x;
} else {
c = x - y + L;
}

long d = gcd(a , b);
if(c%d!=0){
System.out.println("Impossible");
}else{
}
}
}
}

public static long gcd(long a, long b) {
long t, d;
if (b == 0) {
x0 = 1;
y0 = 0;
return a;
}
d = gcd(b, a % b);
t = x0;
x0 = y0;
y0 = t - a / b * y0;
return d;
}

}

1. if(j){
int ans=a ;
for(int x=j-1;x>=0;x–){
if(!a ) break;
ans=min(ans,a );
sum+=ans;
}
}
求解释，，dp的思路是什么呢？

2. #include <cstdio>
#include <algorithm>

struct LWPair{
int l,w;
};

int main() {
//freopen("input.txt","r",stdin);
const int MAXSIZE=5000, MAXVAL=10000;
LWPair sticks[MAXSIZE];
int store[MAXSIZE];
int ncase, nstick, length,width, tmp, time, i,j;
if(scanf("%d",&ncase)!=1) return -1;
while(ncase– && scanf("%d",&nstick)==1) {
for(i=0;i<nstick;++i) scanf("%d%d",&sticks .l,&sticks .w);
std::sort(sticks,sticks+nstick,[](const LWPair &lhs, const LWPair &rhs) { return lhs.l>rhs.l || lhs.l==rhs.l && lhs.w>rhs.w; });
for(time=-1,i=0;i<nstick;++i) {
tmp=sticks .w;
for(j=time;j>=0 && store >=tmp;–j) ; // search from right to left
if(j==time) { store[++time]=tmp; }
else { store[j+1]=tmp; }
}
printf("%dn",time+1);
}
return 0;
}

3. Good task for the group. Hold it up for every yeara??s winner. This is a excellent oppotunity for a lot more enhancement. Indeed, obtaining far better and much better is constantly the crucial. Just like my pal suggests on the truth about ab muscles, he just keeps obtaining much better.

4. 算法是程序的灵魂，算法分简单和复杂，如果不搞大数据类，程序员了解一下简单点的算法也是可以的，但是会算法的一定要会编程才行，程序员不一定要会算法，利于自己项目需要的可以简单了解。