2013
11-07

# 方程的解数

1 <= n <= 6；1 <= M <= 150。

★本题中，指数Pi(i=1,2,…,n)均为正整数。

3
150
1  2
-1  2
1  2

178

//* @author:
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.Scanner;
public class Main
{
static int[]k=new int[6];
static int[]p=new int[6];
static int n,m,mark;
static int total;
static Hashtable< Long,Integer>hash=new Hashtable< Long,Integer>();
public static void main(String[] args)
{
int i,j;
Scanner cin=new Scanner(System.in);
while(cin.hasNext())
{
hash.clear();
total=0;
n=cin.nextInt();
m=cin.nextInt();
for(i=0;i< n;i++)
{
k[i]=cin.nextInt();
p[i]=cin.nextInt();
}
mark=n/2;
dfs(0,0);
dfs2(mark,0);
System.out.println(total);
}
}

static void dfs(int pos,long sum)
{
if(pos==mark)
{
sum*=-1;
if(hash.containsKey(sum))
{
hash.put(sum,hash.get(sum)+1);
}
else
hash.put(sum,1);
return;
}
int i,j;
long tmp;
for(i=1;i<=m;i++)
{
tmp=(long)k[pos];
for(j=0;j< p[pos];j++)
{
tmp*=i;
}
dfs(pos+1,sum+tmp);
}
}

static void dfs2(int pos,long sum)
{
if(pos>=n)
{
if(hash.containsKey(sum))
{
total+=hash.get(sum);
}
return;
}
int i,j;
long tmp;
for(i=1;i<=m;i++)
{
tmp=(long)k[pos];
for(j=0;j< p[pos];j++)
{
tmp*=i;
}
dfs2(pos+1,sum+tmp);
}

}
}

1. bottes vernies blanches

I appreciate the efforts you men and women place in to share blogs on such sort of matters, it was certainly useful. Keep Posting!

2. #include <stdio.h>
int main()
{
int n,p,t[100]={1};
for(int i=1;i<100;i++)
t =i;
while(scanf("%d",&n)&&n!=0){
if(n==1)
printf("Printing order for 1 pages:nSheet 1, front: Blank, 1n");
else {
if(n%4) p=n/4+1;
else p=n/4;
int q=4*p;
printf("Printing order for %d pages:n",n);
for(int i=0;i<p;i++){
printf("Sheet %d, front: ",i+1);
if(q>n) {printf("Blank, %dn",t[2*i+1]);}
else {printf("%d, %dn",q,t[2*i+1]);}
q–;//打印表前
printf("Sheet %d, back : ",i+1);
if(q>n) {printf("%d, Blankn",t[2*i+2]);}
else {printf("%d, %dn",t[2*i+2],q);}
q–;//打印表后
}
}
}
return 0;
}

3. Gucci New Fall Arrivals

This is really nice to know. I hope it will be successful in the future. Good job on this and keep up the good work.