随笔分类 - 模拟
摘要:1,注意字符串的应用0在开头的输出2,注意输出格式俩个数字之间有空列,两个整数之间有空行3,模拟输出一定要注意找规律,是一行一行的输出#include<cstdio>#include<iostream>#include<string>using namespace std;int nums[100000000];int bits(string num)//计算数字的位数并将其整理成数组{ int n,i; i=1; n=num.length(); for(i=0;i<n;i++) nums[i]=num[i]-48; return n;}int ma.
阅读全文
摘要:#include <stdio.h>#include <math.h>#include <string.h>int r;int abs(int a){ if(a<0) return -a; return a;}int judge(int a,int b){ int k=abs((r-a)*(r-a)+(r-b)*(r-b)-r*r); if(k<=3) return 1; else return 0;}int main(){ int t,i,j,u=1; scanf("%d",&t); while(t--) { sca
阅读全文
摘要:注意__int64的设定,关键#include <stdio.h>int main(){ int n,t,s,c; int i,a,b; __int64 sum; int k=1; scanf("%d",&c); while(c--) { scanf("%d%d%d",&n,&t,&s); sum=2*t+s; scanf("%d",&a); for(i=2;i<=n;i++) { scanf("%d",&b); if((b-a)*s>2*t)
阅读全文
摘要:主要是printf("%*c",n,c);的应用,就是c这个字符要占都少个位置#include <stdio.h>int main(void){ char c; int i = 0, n; while ((c = getchar()) != '@') { scanf("%d%*c", &n); printf(i ? "\n%*c\n" : "%*c\n", n, c); if (n == 1) { i = 1; continue; } for...
阅读全文
摘要:其中非常巧妙的运用了b和c变量,还有就是有效地剪枝#include <stdio.h>int A(int n){ int i = 1; while (n) { if (n % 10 == 4 || n % 100 == 62) return i; n /= 10; i *= 10; } return 0;}int main(void){ int n, m, i, c, b; int *a = new int[1000000]; a[0] = 0; for (c = 0,i = ...
阅读全文
摘要:以前总是,得一行打印一行,现在可以将全部存储以后,再一次性输出,很好的方法还有就是行数的奇偶控制,很有效。找出n与,a,b的规律#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int n;char a[81][81];void eva(int x, char c){ int i = x; int j = x; if(2*x>n) a[i][j]=c; else { for(;j...
阅读全文
摘要:本题主要是题意的理解,背景要看规则。模拟的时候一定要注意if判断的顺序,从整体到分支,提高速度#include <stdio.h>int main(){ int n,m,as,ds,i,sum; scanf("%d",&n); while(n--) { scanf("%d%d%d",&m,&as,&ds); sum=0; if(as>ds) { printf("Yes\n"); } else { if(m==0) { printf("No\n"); } else i
阅读全文

浙公网安备 33010602011771号