只有在 Month 和 Day 都为素数的时候才能得到糖

那就模拟一遍时间即可.

//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define pi acos(-1.0) using namespace std; typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ; template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;}
template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;} const double eps = 1e- ;
const int N = ;
const int M = * ;
const ll P = 10000000097ll ;
const int MAXN = ; int month1[] = {, , , , , , , , , , , , };
int month2[] = {, , , , , , , , , , , , }; bool run (int x) {
if (x % == && x % != || x % == ) return true;
return false;
} bool prime (int num){
if (num == ) return false;
for (int i = ; i <= sqrt(num); ++i){
if (num % i == ) return false;
}
return true;
} int main() {
std::ios::sync_with_stdio(false);
int i, j, t, k, u, v, numCase = ;
int y1, y2, m1, m2, d1, d2;
cin >> t;
while (t--) {
cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
int ans = ;
while (y1 < y2) {
if (!run (y1)){
for (; m1 <= ; ++m1) {
for (; d1 <= month1[m1]; ++d1){
if (prime(m1) && prime(d1)) ++ans;
}
d1 = ;
}
} else{
for (; m1 <= ; ++m1) {
for (; d1 <= month2[m1]; ++d1) {
if (prime(m1) && prime(d1)) ++ans;
}
d1 = ;
}
}
m1 = ;
++y1;
}
if (!run (y1)) {
for (; m1 < m2; ++m1) {
for (; d1 <= month1[m1]; ++d1) {
if (prime(m1) && prime(d1)) ++ans;
}
d1 = ;
}
for (; d1 <= d2; ++d1) {
if (prime(m2) && prime(d1)) ++ans;
}
} else{
for (; m1 < m2; ++m1) {
for (; d1 <= month2[m1]; ++d1) {
if(prime(m1) && prime(d1)) ++ans;
}
d1 = ;
}
for (; d1 <= d2; ++d1) {
if(prime(m2) && prime(d1)) ++ans;
}
}
cout << ans << endl;
} return ;
}

ZOJ 3326 An Awful Problem 模拟的更多相关文章

  1. ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)

    题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...

  2. ZOJ 4009 And Another Data Structure Problem(ZOJ Monthly, March 2018 Problem F,发现循环节 + 线段树 + 永久标记)

    题目链接  ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. ...

  3. ZOJ 2392 The Counting Problem(模拟)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1368 题目大意:计算从S到T中所有的数,其中0,1,2,3,4,5, ...

  4. UVALive 3486/zoj 2615 Cells(栈模拟dfs)

    这道题在LA是挂掉了,不过还好,zoj上也有这道题. 题意:好大一颗树,询问父子关系..考虑最坏的情况,30w层,2000w个点,询问100w次,貌似连dfs一遍都会TLE. 安心啦,这肯定是一道正常 ...

  5. hdu_5832_A water problem(模拟)

    题目链接:hdu_5832_A water problem 这是一个惨痛的教训,想这种这么大的大数肯定就是找个规律模拟一下. 然而我们队还写JAVA,用大数艹了13发罚时,真是TM智障了. #incl ...

  6. 详解OJ(Online Judge)中PHP代码的提交方法及要点【举例:ZOJ 1001 (A + B Problem)】

    详解OJ(Online Judge)中PHP代码的提交方法及要点 Introduction of How to submit PHP code to Online Judge Systems  Int ...

  7. ZOJ 1457 Prime Ring Problem(dfs+剪枝)

     Prime Ring Problem Time Limit: 10 Seconds      Memory Limit: 32768 KB A ring is compose of n circ ...

  8. 2016中国大学生程序设计竞赛(长春) Ugly Problem 模拟+大数减法

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5920 我们的思路是: 对于一个串s,先根据s串前一半复制到后一半构成一个回文串, 如果这个回文串比s小, ...

  9. ZOJ 1001 A + B Problem

    熟悉ZOJ环境,如何上传代码,如何查看结果. #include<iostream> using namespace std; int main(){ int a,b; while(cin& ...

随机推荐

  1. HTML+CSS笔记 CSS中级 一些小技巧

    水平居中 行内元素的水平居中 </a></li> <li><a href="#">2</a></li> &l ...

  2. document.createElement在IE和Firefox下的差异

    IE有3种方式都可以创建一个元素: 1 document.createElement("<input type=text>") 2 document.createEle ...

  3. Eclipse运行慢

    http://blog.csdn.net/chrissata/article/details/7759836 http://blog.csdn.net/heyutao007/article/detai ...

  4. Python type类具体的三大分类:metaclasses,classes,instance

    Python type类视角中的对象体系需要我们不断的学习,其中我们使用的时候需要注意.下面我们就看看如何才能更好的运用Python type类.下面的文章希望大家有所收获. 在单纯的Python t ...

  5. hdoj 1532 Drainage Ditches(最大网络流)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1532 思路分析:问题为最大网络流问题,给定一个有向图,需要求解该有向图的最大网络流,使用Edmonds ...

  6. POJ 1655 - Balancing Act 树型DP

    这题和POJ 3107 - Godfather异曲同工...http://blog.csdn.net/kk303/article/details/9387251 Program: #include&l ...

  7. LeetCode :Word Ladder II My Solution

    Word Ladder II Total Accepted: 11755 Total Submissions: 102776My Submissions Given two words (start  ...

  8. GLSL中的各种变量总结

    1.uint CreateShader(enum type) : 创建空的shader object; type: VERTEX_SHADER, 2.void ShaderSource(uint sh ...

  9. iOS中怎样加入自己定义的字体

    苹果对于开发,确实在细节方面下了非常大的功夫,只是不管一个平台下多大的功夫,仍然会有些需求是无法涵盖的.比方字体吧. 我们的应用为了能更加个性化.会须要不同的字体.有时候有些字体是非常特殊的.甚至是购 ...

  10. CSS中 清除浮动解决“包含问题”

    今天看到大神对浮动定位作了个详细的分析  刚好就分析了当时任务三遇到的问题 在一个div中定义了三个div,让横向排列,结果父元素div的背景色显示不出来了 ,这是个经典问题----包含浮动 < ...