您正在查看 "西南交大acm程序设计" 分类下的文章 2009-12-25 12:46 2009-11-06 23:24 这道题刚开始以为是错排。结果一直WA。最后发现错排是错的。得用容斥原理。强大的容斥原理啊。
my code:
#include "stdio.h"
#include "string.h"
__int64 H[10001] ;
int main()
{
int n,m,T,i;
__int64 ans;
//freopen("in.txt","r",stdin);
scanf("%d",&T);
while(T--)
{
|
2009-10-25 15:17 这道题刚开始一直WA,
WA代码:
#include<stdio.h>
#include<string.h>
int n, m, c;
int used[25];
int capacity[25];
int main()
{
int i, num, pc, maxc, counter=0;
//freopen("in.txt","r",stdin);
while (scanf("%d%d%d", &n, &m, &c)>0 && (n || m || c))
{
print |
2009-10-25 0:10 做这道题一直把题目题意理解得不是很准。刚开始没有结合最上面的那个图,以为每个点都可以往上和往下搜索,结果发现当列数是偶数的时候只能往下扩展,为奇数的时候只能往上面扩展,发现这个问题,改一下代码,一下AC,唉,引以为鉴。
my code:(感觉可以优化一下)
#include<iostream>
using namespace std;
#define MAX 205
int n;
char map[MAX][MAX];
int ex |
2009-10-19 10:37 #include<iostream>
#include<string>
#include<cmath>
using namespace std;
int abs( int a)
{
return a>= 0 ? a: -a;
}
typedef struct
{
int x, y;
char d;
}ROBOT;
ROBOT robot[101];
int testnum;
int A, B;
|
2009-10-10 8:44 第一贪心:
#include<iostream>
using namespace std;
int main(void)
{
int n;
int c;
int mincoin;
int mQ,mD,mN,mP;
int counter=0;
cin >> n;
while (n--)
{
cin >> c;
mQ = c/25;
mD = (c - 25*mQ) / 10;
mN = (c - 25*mQ - 10*mD |
2009-10-06 18:37 #include<iostream>
using namespace std;
const int size=10;
int row, col, num;
char map[size][size];
int visit[size][size];
void dfs( int x, int y , int step )
{
|
2009-09-05 22:05 2009-07-17 21:27 #include<stdio.h>
#include<string.h>
#define MAX 1000004
typedef struct{
int x,y;
}Point;
int location[MAX];
void main()
{
int m;
int i,j,t,k,r,c,qn,kn,pn,x,y,counter=1,s1,flag;
long sum;
Point lq,lk,lp;
int fx[8][2]={{-1,-2},{-2,-1},{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2}};
while(scanf("%d%d",&r,&c)>0,r+c)
{
|
2009-07-14 15:06 #include<stdio.h>
#include<math.h>
typedef struct{
double x,y;
}Point2;
Point2 getupperpoint(Point2 p1,Point2 p2)
{
Point2 p;
double A,B,C,a,b,c,l,len3,s;
len3=sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
l=(4+len3)/2;
s=sqrt(fabs(l*(l-2)*(l-2)*(l-len3)));
A=2*(p2.x-p1.x);
B=2*(p2.y-p1.y);
C=p1.x*p1.x+p1.y*p1.y-p2.x*p2.x-p2.y*p2.y;
a=p1.y-p2.y;
b=p2.x-p |
2009-07-05 11:41 #include<stdio.h>
#include<math.h>
#include<stdlib.h>
typedef struct peanuts{
int x,y;
int sum;
}P;
int cmp(const void *a,const void *b)
{
return ((P*)b)->sum-((P*)a)->sum;
}
P pea[2500];
int num,k,m,n,point,t;
int main()
{
int i,j,sum_pea,present_x,present_y,c_time,temp;
scanf("%d",&num);
while(num--)//the number o |
2009-07-04 17:50 #include<stdio.h>
#include<math.h>
typedef struct peanuts{
int x,y;
int sum;
}P;
void quicksort(P data[], int low,int high)
{/*用快速排序方法数组元素data[low..high]作排序*/
int i,j;
int pivot;
P temp=data[low];
if(low<high)/*以数组的第一个元素为基准进行划分*/
{
pivot=data[low].sum;
i=low;
|
2009-07-04 16:11 #include<stdio.h>
void main()
{
int m,n,a[202]={0},i,j,prior,sum;
char matrix[200][200];
scanf("%d%d",&m,&n);
getchar();
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%c",&matrix[i][j]);
getchar();
}
for(i=0;i<n;i++)//列方向上
{
|
2009-06-02 16:06 #include<iostream>
int main()
{
long n,i,counter;
while(std::cin>>n,n!=0)
{
int *a=new int[n];
int *b=new int [n];
for(i=0;i<n;i++)
std::cin>>a[i];
counter=0;
while(1)
{
for( |
2009-06-02 13:36 #include"stdio.h"
#include"string.h"
main()
{
char a[10000];
int b,i,result=0;
while(gets(a),strcmp(a,"end")!=0)
{
for(i=0;a[i];i++)
{
if(a[i]>='0'&&a[i]<='9')
b=a[i]-48;
if(a[i]>='A'&&a[i]<='Z')
b=a[i]-55;
if(a[i]>='a' |
| | |