分析:水题,不解释。
#include
using namespace std;
int cnt[6000];
void init() //打表
{
int i,j;
memset(cnt,0,sizeof(cnt));
cnt[1]=1; //1只有他本身
for(i=2;i<=5005;i++)
{
cnt[i]+=2; //1和他本身
...
分类:
其他好文 时间:
2015-06-02 17:54:49
阅读次数:
223
分析:在除的过程中,当出现相同余数时即出现循环节。
#include
using namespace std;
bool h[100002];
void div(int x)
{
int t;
memset(h,false,x*sizeof(h[0])+1);
h[1]=true;
t=1;
while(t)
{
t=t*10;
cout<<t/x;
t=t%x;
...
分类:
其他好文 时间:
2015-06-02 17:51:31
阅读次数:
249
#include
using namespace std;
int base[4][4]={ //初始状态
{1,1,0,1},
{1,1,1,0},
{0,1,1,1},
{1,0,1,1}};
int a[2][4][4]; //滚动数组
void f(int n)
{
int i,j;
if(n==0)
{
for(i=0;i...
分类:
其他好文 时间:
2015-06-02 09:25:12
阅读次数:
205
分析:注意队列中保存的是排序后数组中的下标。树状数组也是根据下标进行处理。
#include
#include
#include
using namespace std;
#define N 10005
int c[N<<2];
int n,a[N],b[N];
char str[N][10];
int lowbit(int x)
{
return x&(-x);
}
voi...
分类:
编程语言 时间:
2015-06-01 22:52:25
阅读次数:
191
分析:IDA*解决,借鉴大牛的启发式函数h(): 可以考虑把每一行上的数转化成相同的,或者把每一列上的数字转化成相同的,二者取最小值。
例如:
1 1 3 2
2 4 4 2
3 3 1 4
1 2 3 4
把这个矩阵转化成行合法矩阵需要的操作:第一行至少要2次,第二行也是2次, 第三行是2次,第四行是3次, 所以把矩阵转化成行相同至少要3次。
#include
usi...
分类:
编程语言 时间:
2015-06-01 22:39:16
阅读次数:
164
分析:先把每个挑战者的战斗力升序排序,接着找出离m最近的小于m的挑战者的战斗力,然后从该处开始,对后面的每个挑战者进行处理,尽量使百小度提升战斗力后等于后一个挑战者的战斗力。如果激发战斗力后还无法打赢则不行,否则使其相等。
#include
#include
using namespace std;
int main()
{
int T,t,n,m,k,i;
__int64 a...
分类:
其他好文 时间:
2015-06-01 16:46:28
阅读次数:
116
分析:使用STL的set容器实现,set的内部排序默认是从小到达的。先把结果预处理到一个数组中存储起来,之后直接输出即可。
#include
#include
using namespace std;
#define N 10005
int a[N];
int ans[N];
set s; //默认从小到达排序
set::iterator it;
int main() ...
分类:
其他好文 时间:
2015-06-01 16:43:58
阅读次数:
158
欢迎“热爱编程”的高考少年——报考杭州电子科技大学计算机学院
最短路径问题
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 16300 Accepted Submission(s): 4898
...
分类:
其他好文 时间:
2015-06-01 14:50:10
阅读次数:
151
分析:二分代价,由于序列是单增的,我们使前面一个数相对取最小,这样后面的数变化的值也能相对较小(贪心)。
#include
using namespace std;
#define N 100010
#define max(a,b) ((a)>(b)?(a):(b))
int num[N],tmp[N],n;
bool valid(int cost)
{
int i;
for(i=1;...
分类:
其他好文 时间:
2015-05-31 23:17:24
阅读次数:
140
分析:一个图,求图中‘#’组成了多少个十字架,注意十字架的宽度是奇数。对每个‘#’判断,上下左右 ,步长为1 ,2,。。。25是不是都符合条件,符合的话判断个数为奇数即可。
#include
using namespace std;
#define N 50
char map[N][N];
int dir[4][2]={
{-1,0},
{0,-1},
{1,0},
{0,1}};
i...
分类:
其他好文 时间:
2015-05-31 18:31:41
阅读次数:
110