Skip to main content

Posts

Showing posts from August, 2020

Weather News Website

  Prerequisite- 1.HTML 2.CSS 3.Javascript Characteristics of Website- Current Temperature,Max Temperature,Location,Description,Wind Speed. How it Work- We fetch data from API  Step 1- Create account on  https://openweathermap.org/  for Api. step 2- Show json data . Javascript code- <script type = "text/javascript" > window . addEventListener ( "load" ,()=>{ let long ; let lat ; if ( navigator . geolocation ) { navigator . geolocation . getCurrentPosition ( position =>{ long = position . coords . longitude ; late = position . coords . latitude ; const Api = "https://api.openweathermap.org/data/2.5/weather?lat=" + late + "&lon=" + long + "&appid=API KEY" ; //console.log(Api); fetch ( Api ) . then ( response =>{ return response . json (); }) . then ( data =>{ var dt = data ; console . l...

CSES Dynamic Programming Problem Solution+Explanation

Problem 1-Dice Combinations Editorial- Now start from base  1->1 2->1+1,2+0 3->1+1+1,2+1,1+2,3+0 now for-4 we substract from 1 to min(6,4) ( we substract 1 then remaining 3 now we add no.of possible way to constuct 3)+(we substract 2 remaining(4-2=2,no of possible way to constuct 2)+(we substract 3,no. of possible way to construct 1)+(we substract 4 ,now of possible way to construct 0). i think you got the point base condition- dp[0]=1; how dp[0] ,for this there is empty subset exist Solution- #include < bits / stdc ++. h > using namespace std ; #define ll long long int #define str string #define pb push_back #define vc vector #define ci cin #define co cout #define mod 1000000007 ll dp [ 1000010 ];   int main () {   ios_base :: sync_with_stdio ( false ); cin . tie ( NULL ); ll n ; cin >> n ; dp [ 0 ]= 1 ; for ( int i = 1 ; i <= n ; i ++) { ll ans = 0 ; for ( int j = 1 ; j <= min ( 6 ...