xay loves count

2024-01-04 08:19
文章标签 count loves xay

本文主要是介绍xay loves count,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目:

题目链接:

题解:

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e6;
int a[maxn+5],b[maxn+5];
signed main(){int n,ans=0,s1=0;scanf("%lld",&n);for (int i = 0; i < n; ++i) {int x;scanf("%lld",&x);b[x]++;if(x==1) s1++;}ans=ans+s1*s1*s1;for (int i = 2; i <= maxn; ++i) {if(b[i]) ans=ans+s1*b[i]*b[i]*2;}for (int i = 2; i <= 1000; ++i) {if(b[i]) {for (int j = i; j * i <= maxn; ++j) {if (j == i && b[i * j]) ans = ans + b[i] * b[i] * b[i * j];else if (j != i && b[j] && b[i * j])ans = ans + b[i] * b[j] * 2 * b[i * j];}}}printf("%lld\n",ans);return 0;
}

这篇关于xay loves count的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/568710

相关文章

leetcode#38. Count and Say

The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 12. 113. 214. 12115. 111221 1 is read off as “one 1” or 11. 11 is read off

《Learning To Count Everything》CVPR2021

摘要 论文提出了一种新的方法来解决视觉计数问题,即在给定类别中仅有少量标注实例的情况下,对任何类别的对象进行计数。将计数问题视为一个少样本回归任务,并提出了一种新颖的方法,该方法通过查询图像和查询图像中的少量示例对象来预测图像中所有感兴趣对象的存在密度图。此外,还提出了一种新颖的适应策略,使网络能够在测试时仅使用新类别中的少量示例对象来适应任何新的视觉类别。为了支持这一任务,作者还引入了一个包含

class _ContiguousArrayStorage deallocated with non-zero retain count

Xcode报错 : Object 0x11c614000 of class _ContiguousArrayStorage deallocated with non-zero retain count 2. This object's deinit, or something called from it, may have created a strong reference to self w

LeetCode - 38. Count and Say

38. Count and Say  Problem's Link  ---------------------------------------------------------------------------- Mean:  题目意思太晦涩。 1 读出来 就是“1个1” 所以记为“11” 11 读出来 就是“2个1” 所以记为“21” 21 读出来 就是“1个

【HDU】4876 ZCC loves cards 暴力

传送门:【HDU】4876 ZCC loves cards 题目分析: 这题无力吐嘈。。。。能想到的优化都用上吧。。。 代码如下: #include <cstdio>#include <cstring>#include <algorithm>using namespace std ;#define REP( i , n ) for ( int i =

【HDU】4873 ZCC Loves Intersection 数学

传送门:【HDU】4873 ZCC Loves Intersection 题目大意:给你一个D维的空间,每个维度都有一条线段平行与该维度属于的轴(如X,Y,Z轴),且线段的端点坐标取值范围0~N-1,保证左端点严格小于右端点(除该维度,其他维度的值两端点均相等)。现在告诉你每条线段的左右端点的坐标都是随机的,0~N-1随机到的概率是完全相等的!现在如果两条线段如果相交于一点,你可以获得一点

【FZU】2105 Digits Count 线段树

传送门:【FZU】2105 Digits Count 题目分析:与、或、异或三种操作都是每一位相互独立的,所以可以将线段树建四棵,分别对应一位,and和or操作相当于覆盖操作,xor操作相当于反转操作,就和普通的线段树方法类似,设立两个lazy标记即可。查询的时候求得每一位的1的个数*权重(1,2,4,8),全部累加就是答案。 代码如下: #include <cst

【HDU】5197 DZY Loves Orzing 【FFT启发式合并】

传送门:【HDU】5197 DZY Loves Orzing 题目分析: 首先申明,我不会 dp dp方程= =……这个东西给队友找出来了,然后我就是套这个方程做题的Qrz…… 对于这题,因为 n2 n^2个数互不相同,所以每一列都可以单独考虑。设 dpni dp_ni表示长度为 n n的排列,能恰好看见ii个人的方案数,根据队友的发现, dpni dp_ni就等于 |sni| |s_ni|

CodeForces 451D Count Good Substrings

题意: 一个只包含a和b的字符串  问  它有几个长度为偶数和长度为奇数的“压缩回文串”  压缩的概念是  相邻的相同字符压缩成一个字符 思路: 串经过压缩一定满足如下形式 ……ababab……  那么这样只要两端的字符相同则中间一定是回文的  因此对于一个a它作为左端点形成的回文串个数就等于它右边的a的个数  那么长度是奇数还是偶数呢  可以这么判断  如果a在奇数位置上和它匹配的a也在奇

Count Palindrome in String

string 有多少palindrome substring。exp: 'aba' 返回4 , 'abba' 返回6 public class CountPalindrome {public int countPalindrome(String str){if(str == null || str.length() == 0) return 0;int count = 0;for(int