1743A - Password - CodeForces Solution


implementation

Please click on ads to support us..

Python Code:

for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    l = 10 - n;
    ans = 6*l*(l-1)
    print(ans//2)

C++ Code:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000010;
int a[N];
int fact[N],infact[N];
int power(int a,int b) 
{
    int ans = 1;
    while (b) 
	{
        if (b & 1) ans = (ll)ans * a ;
        b >>= 1;
        a = (ll)a * a ;
    }
    return ans;
}
void cf()
{
	ll n;
	map<int,int>mp;
	cin>>n;
	ll cnt=0;
	for(int i=1;i<=n;i++)
	{
	cin>>a[i];
	mp[a[i]]++;
}
	for(int i=0;i<=9;i++)if(mp[i]==0)cnt++;//统计有多少个数字没有用
	cout<<cnt*(cnt-1)/2*6<<endl;
}
int main()
{
	
	ll t;
	cin>>t;
	while(t--)
	{
		cf();
	}
	
	
	return 0;
}


Comments

Submit
0 Comments
More Questions

1438A - Specific Tastes of Andre
1711C - Color the Picture
1194C - From S To T
110B - Lucky String
1114A - Got Any Grapes
224B - Array
125B - Simple XML
567B - Berland National Library
431B - Shower Line
282C - XOR and OR
1582B - Luntik and Subsequences
609A - Флеш-карты
1207A - There Are Two Types Of Burgers
371C - Hamburgers
343B - Alternating Current
758B - Blown Garland
1681B - Card Trick
1592A - Gamer Hemose
493D - Vasya and Chess
1485A - Add and Divide
337B - Routine Problem
1392D - Omkar and Bed Wars
76E - Points
762C - Two strings
802M - April Fools' Problem (easy)
577B - Modulo Sum
1555B - Two Tables
1686A - Everything Everywhere All But One
1469B - Red and Blue
1257B - Magic Stick