素数个数; 刚打完,以下代码: #include<cstdio>#include<cmath>using namespace std; int prime(int n){int j;if(n==2) return 1;j=2;while(j<=sqrt(n)&&n%j!=0)j++;if(n%j== ...
分类:
其他好文 时间:
2020-01-30 12:27:28
阅读次数:
60
https://vjudge.net/problem/POJ-3126 题意:T组数据,每组数据给你两个四位数 a 和 b. 每次你可以变幻四位数 a 某个位置上的数字,得到一个新的四位数 t,并且 t 是素数, 问变幻多少次后,可以得到四位数 b. 题解:埃式筛法求素数(暴力求素数应该也可,口嗨) ...
分类:
其他好文 时间:
2020-01-30 10:07:05
阅读次数:
62
"传送门" 题意: 给出一颗有根树,每个结点有一个权值$a_i,1\leq a_i\leq 10^9$;同时,每个结点有一个值$c_i$,表示其子树中有多少个结点,满足$a_j include include include include include include include inclu ...
分类:
其他好文 时间:
2020-01-30 00:00:30
阅读次数:
129
Given two sets of integers, the similarity of the sets is defined to be /, where N?c?? is the number of distinct common numbers shared by the two sets ...
分类:
其他好文 时间:
2020-01-29 21:54:49
阅读次数:
84
String.format()字符串常规类型格式化的两种重载方式 format(String format, Object… args) 新字符串使用本地语言环境,制定字符串格式和参数生成格式化的新字符串。 format(Locale locale, String format, Object… a ...
分类:
其他好文 时间:
2020-01-29 14:09:29
阅读次数:
102
题解: 第一次: 算法复杂度过高,导致编译超时,需要优化 #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 ...
分类:
其他好文 时间:
2020-01-29 14:06:40
阅读次数:
56
Garland题意题解代码Numbers on Tree题意题解代码Garland题目链接 http://codeforces.com/contest/1286/problem/A题意给出一串灯泡,灯泡上编号为 1~n 的一个排列,其中一些灯泡掉落。定义整串的权值为相邻灯泡编号奇偶不同的对数,求放回... ...
分类:
其他好文 时间:
2020-01-28 23:36:10
阅读次数:
134
You are given an undirected graph consisting of nn vertices and mm edges. Your task is to find the number of connected components which are cycles. He ...
分类:
其他好文 时间:
2020-01-28 19:13:14
阅读次数:
152
C 语言竞赛是浙江大学计算机学院主持的一个欢乐的竞赛。既然竞赛主旨是为了好玩,颁奖规则也就制定得很滑稽: 0、冠军将赢得一份“神秘大奖”(比如很巨大的一本学生研究论文集……)。 1、排名为素数的学生将赢得最好的奖品 —— 小黄人玩偶! 2、其他人将得到巧克力。 给定比赛的最终排名以及一系列参赛者的 ...
分类:
编程语言 时间:
2020-01-28 12:41:15
阅读次数:
73
C++ 11提供的智能指针有:shared_ptr、unique_ptr、weak_ptr。在 头文件 memory 中。 一、new delete 直接管理内存 1、初始化 string * ps = new string // 初始换为一个空string int * pi = new int ; ...
分类:
编程语言 时间:
2020-01-28 10:49:44
阅读次数:
99