USACO 1.4 Arithmetic Progressions (暴力搜索)
来源:互联网 发布:java jdk 32官网下载 编辑:程序博客网 时间:2024/06/14 02:16
#include <stdio.h>#define DEBUG 1#define TESTCASES 9#define MAX 250int lenOfProgressions;int upperBound;//双平方数的哈希int isBisquare[2 * MAX * MAX + 1];int main(){#if DEBUGint testCase;for (testCase = 1; testCase <= TESTCASES; testCase++){char inputFileName[20] = "inputx.txt";inputFileName[5] = '1' + (testCase - 1);freopen(inputFileName, "r", stdin);printf("\n#%d\n", testCase);#endifscanf("%d%d", &lenOfProgressions, &upperBound);int i;for (i = 0; i < max; i++)isBisquare[i] = 0;int p, q;for (p = 0; p <= upperBound; p++)for (q = 0; q <= upperBound; q++)isBisquare[p * p + q * q] = 1;int max = 2 * upperBound * upperBound;int hasNoProgressions = 1;int a, b;//因为输出要先按b排序再按a排序,所以先枚举b,再枚举afor (b = 1; b <= max; b++)for (a = 0; a + (lenOfProgressions - 1) * b <= max; a++){int isProgressions = 1;int n;for (n = 0; n < lenOfProgressions; n++)if (isBisquare[a + n * b] == 0){isProgressions = 0;break;}if (isProgressions){hasNoProgressions = 0;printf("%d %d\n", a, b);}}if (hasNoProgressions)printf("NONE\n");#if DEBUG}#endifreturn 0;}
0 0
- USACO 1.4 Arithmetic Progressions (暴力搜索)
- USACO Section 1.4 - Arithmetic Progressions (暴力)
- usaco Arithmetic Progressions 暴力破解
- USACO Arithmetic Progressions(暴力)
- USACO 1.4-Arithmetic Progressions
- [usaco]1.4 Arithmetic Progressions
- usaco 1.4 Arithmetic Progressions
- USACO 1.4 Arithmetic Progressions
- USACO 1.4 Arithmetic Progressions
- USACO 1.4-Arithmetic Progressions
- USACO 1.4 Arithmetic Progressions
- USACO-Section1.4 Arithmetic Progressions【暴力枚举】
- USACO 1.4.4 Arithmetic Progressions
- [USACO 1.4.3] Arithmetic Progressions
- usaco 1.4.4 Arithmetic Progressions
- USACO 1.4.4 Arithmetic Progressions
- USACO Section 1.4 Arithmetic Progressions
- USACO 1.4 Arithmetic Progressions (ariprog)
- LAN、WAN、WLAN、VLAN和VPN的区别
- poj2159 初识hash
- 【bzoj2709】 迷宫花园 spfa
- iOS项目开发实战——使用CALayer和定时器实现进度条
- Codeblocks中文字体反转
- USACO 1.4 Arithmetic Progressions (暴力搜索)
- Luci实现框架
- 测试职业思考
- 关于文件浏览的自定义Web服务器
- UI设计-zTree(4)
- 互联网金融IT解决方案和服务供应商
- 关于Mantis
- 我的Android设计模式(二) 观察者模式
- Java知识点