随笔分类 -  洛谷

摘要:题解: #include<stdio.h>#include<math.h>int main(){ int n; scanf("%d",&n); int a[20000]={0}; int i,j; for(i=4;i<20000;i+=2){ a[i]=1; } for(i=3;i<sqrt(200 阅读全文
posted @ 2020-02-01 11:23 BlueValentines 阅读(159) 评论(0) 推荐(0)
摘要:题解: 此题需要先排序在进行计算 #include<stdio.h>void swap(int *a,int *b){ int t=*a; *a=*b; *b=t;} //void sort(int a[],int s,int e,int b[]){// if(s>=e){// return;//  阅读全文
posted @ 2020-01-31 13:28 BlueValentines 阅读(136) 评论(0) 推荐(0)
摘要:题解: 错误的: #include<stdio.h>int n,ret=0,a[10000][10];int p(int c,int s){ int i; for(i=1;i<=3;i++){ s+=i; if(c==9){ if(s==n){ a[ret][c]=i; ret++; return 阅读全文
posted @ 2020-01-30 19:15 BlueValentines 阅读(113) 评论(0) 推荐(0)
摘要:题解: 第一次: 算法复杂度过高,导致编译超时,需要优化 #include<stdio.h>#include<math.h>int a[100000001] = { 0 };int p(int n) { int t = n, ret = 0; while (t > 0) { t /= 10; ret 阅读全文
posted @ 2020-01-29 12:36 BlueValentines 阅读(120) 评论(0) 推荐(0)
摘要:题解: #include<stdio.h>int a[10]={6,2,5,5,4,5,6,3,7,6};int num(int n){ //计算所需火柴棒的个数 int sum=0; sum+=a[n%10]; //小心特殊情况——0 while(n>9){ n/=10; sum+=a[n%10] 阅读全文
posted @ 2020-01-28 10:32 BlueValentines 阅读(117) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<math.h>int x[20],n,k,i; //判断是否质数 int isprime(int n){ for(i=2;i<=sqrt(n);i++){ if(n%i==0)return 0; } return 1;} ************* 阅读全文
posted @ 2020-01-27 18:26 BlueValentines 阅读(159) 评论(0) 推荐(0)