B.A Lot of Joy (数学期望)

B. A Lot of Joy

time limit per test

2.0 s

memory limit per test

256 MB

input

standard input

output

standard output

Two boys Gena and Petya wrote on two strips of paper the same string s that consisted of lowercase Latin letters. Then each boy took one strip, cut it into small pieces so that each piece contained exactly one letter and put all pieces into his pocket. After that Gena and Petya repeated the following procedure until their pockets became empty: they took one piece from their pockets and rejoiced if the letters on these pieces were equal.

Determine the expected number of times the boys rejoiced during this process.

Input

The input contains the only string s which was initially written on Gena's and Petya's strips. The string has length between 1 and 200000, inclusively, and consists of lowercase Latin letters.

Output

Output the only real number — the expected number of times Gena and Petya rejoiced during their business. The absolute or relative error of the answer should not exceed 10 - 9.

Examples

input

Copy

abc

output

Copy

1.000000000000000

input

Copy

zzz

output

Copy

3.000000000000000

Examples

Input

abc

Output

1.000000000000000

Input

zzz

Output

3.000000000000000

题目连接:http://codeforces.com/gym/100187/problem/B 

这种像水题的东西就用找规律的思想

abc == 1/3

aab ==5/3 ==4/3+1/3 这里4是2+2还是2*2不确定 

aaa ==3  == 9/3=3*3/3 这样就找到规律了

#include<cstdio>
#include<cstring>
char str[200010];
int a[30];
int main()
{
        int i;
	    scanf("%s",str);
		int l=strlen(str);
		memset(a,0,sizeof(a));
		for(i=0;i<l;i++)
		{
			a[str[i]-'a']++;
		}
		double ans=0.0;
		for(i=0;i<26;i++)
		{
			ans+=(double)a[i]*a[i]/l;
		}
		printf("%0.15lf\n",ans);
	    return 0;
}

 

找出sql错误SELECT * FROM ( SELECT a.id, a.CODE AS 'sourceBillCode', a.type AS 'originalOrderType', a.unit_of_origin, a.unit_of_origin_type, a.time AS 'orderOriginCreationTime', a.warehouse, a.receiving_storage_space, b.type_of_material, b.quality_control_number, b.good_products_number, b.defective_products_number, b.yield, b.quantity_of_returns, b.as_received_condition, b.quantity_of_order, b.quantity_not_received, b.quantity_of_goods_received, b.number_of_spare_parts, b.quantity_of_returns_actual, b.special_production_quantity, b.quantity_in_storage, b.receipt_quantity AS 'inqty', b.quantity_not_in_storage FROM wareh_source_order a LEFT JOIN statistics_receiving_order b ON a.id = b.order_id UNION ALL SELECT a.id, a.CODE AS 'sourceBillCode', a.type AS 'originalOrderType', a.unit_of_origin, a.source_of_delivery_note, a.time AS 'orderOriginCreationTime', a.warehouse, a.receiving_storage_space, b.type_of_material, b.quality_control_number, b.good_products_number, b.defective_products_number, b.yield, b.quantity_of_returns, b.as_received_condition, b.quantity_of_order, b.quantity_not_received, b.quantity_of_goods_received, b.number_of_spare_parts, b.quantity_of_returns_actual, b.special_production_quantity, b.quantity_in_storage, b.receipt_quantity AS 'inqty', b.quantity_not_in_storage FROM wareh_source_order a LEFT JOIN statistics_purchase_order b ON a.id = b.order_id ) tab WHERE originalOrderType IN ( 'PurchaseOrder', 'ReceiptRecord' ) AND warehouse = 'string' AND receiving_storage_space = 'string' AND date_format( orderOriginCreationTime, '%y%m%d' ) >= date_format( '2023-07-07 00:00:00.0', '%y%m%d' ) AND date_format( orderOriginCreationTime, '%y%m%d' ) <= date_format( '2023-07-07 00:00:00.0', '%y%m%d' ) AND ( EXISTS ( SELECT material_no FROM wareh_source_order_list c WHERE c.order_id = id AND ( c.material_name REGEXP 'string' OR c.material_full REGEXP 'string' OR c.material_lot REGEXP 'string' ) ) OR source_of_delivery_note REGEXP 'string' OR CONVERT ( source_bill_code USING utf8mb4 ) REGEXP 'string' )
最新发布
07-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值