2013
12-13

# 九度-1183-守形数[解题代码]

25
4

Yes!
No!

java 代码如下：
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while(s.hasNextInt()){

int n = s.nextInt();
if( n==6 || n==5 )
System.out.println("Yes!");
else{
if(n<10)
System.out.println("No!");
else{
if(n*n % 100 == n)
System.out.println("Yes!");
else
System.out.println("No!");
}

}
}
}

}

/**************************************************************
Problem: 1183
User: coder
Language: Java
Result: Accepted
Time:180 ms
Memory:16964 kb
****************************************************************/

1. 换句话说，A[k/2-1]不可能大于两数组合并之后的第k小值，所以我们可以将其抛弃。
应该是，不可能小于合并后的第K小值吧

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;
}