Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Expected GCD
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include<bits/stdc++.h> using namespace std; #define ll long logn int #define pb push_back #define N=200000; #define mod 1000000007 int main() { int t; cin>>t; while(t--) { int n; cin>>n; int a[n],b[n]; for(int i=0;i<n;i++) cin>>a[i]>>b[i]; ll dp[N+1]={0}; for(int i=1;i<=2000000;i++) { ll p=1; for(int j=0;j<n;j++) { p=(p*(b[j]/i-(a[j]-1)/i))%mod; } dp[i]=p; } ll sum=0; for(int i=200000;i>=1;i--) { for(int j=i*2;j<=200000;j=i+j) { dp[i]-=dp[j]; } sum=(sum+i*dp[i])%mod; } } }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion