B. Alice and the List of Presents

http://codeforces.com/contest/1236/problem/B 

#include <bits/stdc++.h>
//#include <cmath>
//#include <iostream>
//#include <unordered_map>

#define mem(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define INF 0x3f3f3f3f
#define ll long long
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int mod=1e9+7;
const int N=2e5+9;

ll ksm(ll x,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return ans;
}

int main()
{
    FAST_IO;

    int n,m;
    cin>>n>>m;

    cout<<ksm((ksm(2,m)-1+mod)%mod,n)<<endl;

    return 0;
}

 

Sure! For reading and processing the CSV file, we can use the `csv` module in Python. Here's the code to read and collect all the scores in a list: ```python import csv scores = [] with open('midterm.csv', newline='') as csvfile: reader = csv.reader(csvfile) next(reader) # skip header row for row in reader: scores.append(int(row[1])) print(scores) ``` This code will create a list `scores` containing all the numeric scores from the CSV file. For the second part of the question, we need to classify the scores into A, B, C, D, and F categories. According to the criteria given in Problem Set 1, we can use the following classification: - A: score >= 90 - B: 80 <= score < 90 - C: 70 <= score < 80 - D: 60 <= score < 70 - F: score < 60 Here's the code to classify the scores and count the number of scores in each category: ```python counts = {'A': 0, 'B': 0, 'C': 0, 'D': 0, 'F': 0} for score in scores: if score >= 90: counts['A'] += 1 elif score >= 80: counts['B'] += 1 elif score >= 70: counts['C'] += 1 elif score >= 60: counts['D'] += 1 else: counts['F'] += 1 print(counts) ``` This code will create a dictionary `counts` containing the number of scores in each category. Finally, we can use the `plotly` library to create a histogram of the scores. Here's the complete code: ```python import csv import plotly.graph_objs as go scores = [] with open('midterm.csv', newline='') as csvfile: reader = csv.reader(csvfile) next(reader) # skip header row for row in reader: scores.append(int(row[1])) counts = {'A': 0, 'B': 0, 'C': 0, 'D': 0, 'F': 0} for score in scores: if score >= 90: counts['A'] += 1 elif score >= 80: counts['B'] += 1 elif score >= 70: counts['C'] += 1 elif score >= 60: counts['D'] += 1 else: counts['F'] += 1 labels = ['A', 'B', 'C', 'D', 'F'] values = [counts[label] for label in labels] fig = go.Figure([go.Bar(x=labels, y=values)]) fig.show() ``` This code will create a histogram of the scores, showing the number of scores in each category.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值